Nuitka-winsvc 2.4.11__cp311-cp311-win_amd64.whl → 2.5.6__cp311-cp311-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of Nuitka-winsvc might be problematic. Click here for more details.
- {Nuitka_winsvc-2.4.11.dist-info → Nuitka_winsvc-2.5.6.dist-info}/METADATA +56 -109
- {Nuitka_winsvc-2.4.11.dist-info → Nuitka_winsvc-2.5.6.dist-info}/RECORD +304 -280
- {Nuitka_winsvc-2.4.11.dist-info → Nuitka_winsvc-2.5.6.dist-info}/WHEEL +1 -1
- nuitka/Builtins.py +31 -0
- nuitka/HardImportRegistry.py +8 -0
- nuitka/MainControl.py +9 -4
- nuitka/OptionParsing.py +108 -54
- nuitka/Options.py +69 -13
- nuitka/OutputDirectories.py +7 -2
- nuitka/PostProcessing.py +69 -38
- nuitka/Progress.py +16 -1
- nuitka/PythonVersions.py +2 -1
- nuitka/Serialization.py +4 -2
- nuitka/Tracing.py +69 -1
- nuitka/Version.py +2 -2
- nuitka/build/Backend.scons +45 -5
- nuitka/build/CCompilerVersion.scons +6 -0
- nuitka/build/Onefile.scons +6 -0
- nuitka/build/SconsCaching.py +4 -0
- nuitka/build/SconsCompilerSettings.py +14 -3
- nuitka/build/SconsInterface.py +3 -0
- nuitka/build/SconsUtils.py +5 -0
- nuitka/build/include/nuitka/allocator.h +124 -1
- nuitka/build/include/nuitka/calling.h +6 -6
- nuitka/build/include/nuitka/compiled_asyncgen.h +10 -7
- nuitka/build/include/nuitka/compiled_frame.h +2 -1
- nuitka/build/include/nuitka/constants.h +8 -0
- nuitka/build/include/nuitka/debug_settings.h +60 -0
- nuitka/build/include/nuitka/exceptions.h +264 -121
- nuitka/build/include/nuitka/helper/attributes.h +0 -4
- nuitka/build/include/nuitka/helper/calling_generated.h +52 -52
- nuitka/build/include/nuitka/helper/comparisons_dual_eq.h +47 -0
- nuitka/build/include/nuitka/helper/comparisons_dual_ge.h +39 -0
- nuitka/build/include/nuitka/helper/comparisons_dual_gt.h +39 -0
- nuitka/build/include/nuitka/helper/comparisons_dual_le.h +47 -0
- nuitka/build/include/nuitka/helper/comparisons_dual_lt.h +47 -0
- nuitka/build/include/nuitka/helper/comparisons_dual_ne.h +39 -0
- nuitka/build/include/nuitka/helper/dictionaries.h +75 -31
- nuitka/build/include/nuitka/helper/ints.h +86 -37
- nuitka/build/include/nuitka/helper/iterators.h +82 -34
- nuitka/build/include/nuitka/helper/operations.h +3 -0
- nuitka/build/include/nuitka/helper/operations_binary_add.h +6 -0
- nuitka/build/include/nuitka/helper/operations_binary_dual_add.h +34 -0
- nuitka/build/include/nuitka/helper/operations_binary_sub.h +6 -0
- nuitka/build/include/nuitka/helper/operations_inplace_add.h +3 -0
- nuitka/build/include/nuitka/helper/operations_inplace_sub.h +3 -0
- nuitka/build/include/nuitka/helper/raising.h +47 -28
- nuitka/build/include/nuitka/helper/richcomparisons.h +7 -0
- nuitka/build/include/nuitka/helper/tuples.h +12 -0
- nuitka/build/include/nuitka/helpers.h +12 -2
- nuitka/build/include/nuitka/prelude.h +36 -25
- nuitka/build/include/nuitka/printing.h +9 -7
- nuitka/build/include/nuitka/threading.h +15 -1
- nuitka/build/include/nuitka/type_aliases.h +3 -0
- nuitka/build/inline_copy/stubgen/astunparse.py +938 -0
- nuitka/build/inline_copy/stubgen/six.py +998 -0
- nuitka/build/inline_copy/stubgen/stubgen.py +307 -0
- nuitka/build/static_src/CompiledAsyncgenType.c +45 -39
- nuitka/build/static_src/CompiledCellType.c +6 -4
- nuitka/build/static_src/CompiledCodeHelpers.c +106 -40
- nuitka/build/static_src/CompiledCoroutineType.c +41 -31
- nuitka/build/static_src/CompiledFrameType.c +110 -79
- nuitka/build/static_src/CompiledFunctionType.c +173 -151
- nuitka/build/static_src/CompiledGeneratorType.c +51 -49
- nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +433 -46
- nuitka/build/static_src/CompiledMethodType.c +6 -12
- nuitka/build/static_src/HelpersAllocator.c +266 -28
- nuitka/build/static_src/HelpersAttributes.c +0 -21
- nuitka/build/static_src/HelpersBuiltin.c +23 -14
- nuitka/build/static_src/HelpersCalling.c +7 -7
- nuitka/build/static_src/HelpersCallingGenerated.c +70 -70
- nuitka/build/static_src/HelpersComparisonDualEq.c +183 -0
- nuitka/build/static_src/HelpersComparisonDualGe.c +121 -0
- nuitka/build/static_src/HelpersComparisonDualGt.c +121 -0
- nuitka/build/static_src/HelpersComparisonDualLe.c +183 -0
- nuitka/build/static_src/HelpersComparisonDualLt.c +183 -0
- nuitka/build/static_src/HelpersComparisonDualNe.c +121 -0
- nuitka/build/static_src/HelpersComparisonEq.c +18 -4
- nuitka/build/static_src/HelpersComparisonGe.c +18 -4
- nuitka/build/static_src/HelpersComparisonGt.c +18 -4
- nuitka/build/static_src/HelpersComparisonLe.c +18 -4
- nuitka/build/static_src/HelpersComparisonLt.c +18 -4
- nuitka/build/static_src/HelpersComparisonNe.c +18 -4
- nuitka/build/static_src/HelpersConsole.c +34 -8
- nuitka/build/static_src/HelpersConstantsBlob.c +4 -2
- nuitka/build/static_src/HelpersDeepcopy.c +1 -0
- nuitka/build/static_src/HelpersDictionaries.c +195 -36
- nuitka/build/static_src/HelpersDictionariesGenerated.c +12 -107
- nuitka/build/static_src/HelpersExceptions.c +24 -50
- nuitka/build/static_src/HelpersFiles.c +79 -5
- nuitka/build/static_src/HelpersImport.c +13 -9
- nuitka/build/static_src/HelpersImportHard.c +23 -46
- nuitka/build/static_src/HelpersLists.c +98 -9
- nuitka/build/static_src/HelpersOperationBinaryAdd.c +224 -6
- nuitka/build/static_src/HelpersOperationBinaryAddUtils.c +3 -0
- nuitka/build/static_src/HelpersOperationBinaryBitand.c +5 -5
- nuitka/build/static_src/HelpersOperationBinaryBitor.c +5 -5
- nuitka/build/static_src/HelpersOperationBinaryBitxor.c +5 -5
- nuitka/build/static_src/HelpersOperationBinaryDivmod.c +8 -2
- nuitka/build/static_src/HelpersOperationBinaryDualAdd.c +172 -0
- nuitka/build/static_src/HelpersOperationBinaryFloordiv.c +14 -8
- nuitka/build/static_src/HelpersOperationBinaryLshift.c +36 -36
- nuitka/build/static_src/HelpersOperationBinaryMatmult.c +1 -0
- nuitka/build/static_src/HelpersOperationBinaryMod.c +22 -10
- nuitka/build/static_src/HelpersOperationBinaryMult.c +17 -7
- nuitka/build/static_src/HelpersOperationBinaryOlddiv.c +14 -8
- nuitka/build/static_src/HelpersOperationBinaryPow.c +24 -24
- nuitka/build/static_src/HelpersOperationBinaryRshift.c +4 -4
- nuitka/build/static_src/HelpersOperationBinarySub.c +229 -8
- nuitka/build/static_src/HelpersOperationBinaryTruediv.c +8 -2
- nuitka/build/static_src/HelpersOperationInplaceAdd.c +162 -10
- nuitka/build/static_src/HelpersOperationInplaceBitand.c +5 -5
- nuitka/build/static_src/HelpersOperationInplaceBitor.c +5 -5
- nuitka/build/static_src/HelpersOperationInplaceBitxor.c +5 -5
- nuitka/build/static_src/HelpersOperationInplaceFloordiv.c +11 -6
- nuitka/build/static_src/HelpersOperationInplaceLshift.c +20 -20
- nuitka/build/static_src/HelpersOperationInplaceMatmult.c +1 -0
- nuitka/build/static_src/HelpersOperationInplaceMod.c +11 -6
- nuitka/build/static_src/HelpersOperationInplaceMult.c +11 -6
- nuitka/build/static_src/HelpersOperationInplaceOlddiv.c +11 -6
- nuitka/build/static_src/HelpersOperationInplacePow.c +20 -20
- nuitka/build/static_src/HelpersOperationInplaceRshift.c +4 -4
- nuitka/build/static_src/HelpersOperationInplaceSub.c +163 -10
- nuitka/build/static_src/HelpersOperationInplaceTruediv.c +6 -1
- nuitka/build/static_src/HelpersProfiling.c +1 -1
- nuitka/build/static_src/HelpersRaising.c +255 -310
- nuitka/build/static_src/HelpersStrings.c +1 -1
- nuitka/build/static_src/HelpersTuples.c +2 -2
- nuitka/build/static_src/HelpersTypes.c +98 -2
- nuitka/build/static_src/MainProgram.c +132 -28
- nuitka/build/static_src/MetaPathBasedLoader.c +18 -19
- nuitka/build/static_src/MetaPathBasedLoaderResourceReaderFiles.c +134 -11
- nuitka/build/static_src/OnefileBootstrap.c +6 -1
- nuitka/code_generation/AsyncgenCodes.py +2 -6
- nuitka/code_generation/BinaryOperationHelperDefinitions.py +269 -167
- nuitka/code_generation/BuiltinCodes.py +9 -1
- nuitka/code_generation/CallCodes.py +16 -16
- nuitka/code_generation/CodeGeneration.py +14 -2
- nuitka/code_generation/CodeHelperSelection.py +1 -1
- nuitka/code_generation/CodeHelpers.py +4 -1
- nuitka/code_generation/CodeObjectCodes.py +2 -2
- nuitka/code_generation/ComparisonCodes.py +13 -2
- nuitka/code_generation/ComparisonHelperDefinitions.py +23 -8
- nuitka/code_generation/Contexts.py +28 -16
- nuitka/code_generation/CoroutineCodes.py +2 -6
- nuitka/code_generation/DictCodes.py +3 -3
- nuitka/code_generation/ErrorCodes.py +34 -50
- nuitka/code_generation/ExceptionCodes.py +165 -96
- nuitka/code_generation/ExpressionCTypeSelectionHelpers.py +25 -10
- nuitka/code_generation/FrameCodes.py +4 -11
- nuitka/code_generation/FunctionCodes.py +2 -6
- nuitka/code_generation/GeneratorCodes.py +2 -6
- nuitka/code_generation/GlobalConstants.py +8 -2
- nuitka/code_generation/GlobalsLocalsCodes.py +2 -2
- nuitka/code_generation/IteratorCodes.py +67 -54
- nuitka/code_generation/LineNumberCodes.py +1 -3
- nuitka/code_generation/ModuleCodes.py +28 -4
- nuitka/code_generation/OperationCodes.py +51 -20
- nuitka/code_generation/PackageResourceCodes.py +37 -0
- nuitka/code_generation/RaisingCodes.py +164 -90
- nuitka/code_generation/Reports.py +13 -5
- nuitka/code_generation/ReturnCodes.py +2 -16
- nuitka/code_generation/TryCodes.py +12 -24
- nuitka/code_generation/TypeAliasCodes.py +48 -0
- nuitka/code_generation/VariableCodes.py +99 -40
- nuitka/code_generation/VariableDeclarations.py +8 -8
- nuitka/code_generation/YieldCodes.py +1 -1
- nuitka/code_generation/c_types/CTypeBases.py +10 -2
- nuitka/code_generation/c_types/CTypeModuleDictVariables.py +3 -0
- nuitka/code_generation/c_types/CTypeNuitkaBooleans.py +3 -4
- nuitka/code_generation/c_types/CTypeNuitkaInts.py +70 -25
- nuitka/code_generation/c_types/CTypeNuitkaVoids.py +1 -1
- nuitka/code_generation/c_types/CTypePyObjectPointers.py +16 -6
- nuitka/code_generation/templates/CodeTemplatesAsyncgens.py +2 -2
- nuitka/code_generation/templates/CodeTemplatesConstants.py +11 -3
- nuitka/code_generation/templates/CodeTemplatesCoroutines.py +2 -2
- nuitka/code_generation/templates/CodeTemplatesExceptions.py +15 -16
- nuitka/code_generation/templates/CodeTemplatesFrames.py +18 -10
- nuitka/code_generation/templates/CodeTemplatesFunction.py +2 -2
- nuitka/code_generation/templates/CodeTemplatesGeneratorFunction.py +2 -2
- nuitka/code_generation/templates/CodeTemplatesIterators.py +1 -35
- nuitka/code_generation/templates/CodeTemplatesModules.py +34 -4
- nuitka/code_generation/templates/CodeTemplatesVariables.py +76 -0
- nuitka/code_generation/templates_c/CodeTemplateCallsMixed.c.j2 +3 -3
- nuitka/code_generation/templates_c/CodeTemplateCallsPositional.c.j2 +3 -3
- nuitka/code_generation/templates_c/HelperDictionaryCopy.c.j2 +4 -106
- nuitka/code_generation/templates_c/HelperImportHard.c.j2 +1 -2
- nuitka/code_generation/templates_c/HelperLongTools.c.j2 +1 -1
- nuitka/code_generation/templates_c/HelperOperationBinaryDual.c.j2 +115 -0
- nuitka/code_generation/templates_c/HelperOperationComparisonBytes.c.j2 +9 -9
- nuitka/code_generation/templates_c/HelperOperationComparisonDual.c.j2 +86 -0
- nuitka/code_generation/templates_c/HelperOperationComparisonFloat.c.j2 +1 -1
- nuitka/code_generation/templates_c/HelperOperationComparisonInt.c.j2 +1 -1
- nuitka/code_generation/templates_c/HelperOperationComparisonList.c.j2 +9 -9
- nuitka/code_generation/templates_c/HelperOperationComparisonLong.c.j2 +7 -7
- nuitka/code_generation/templates_c/HelperOperationComparisonStr.c.j2 +9 -9
- nuitka/code_generation/templates_c/HelperOperationComparisonTuple.c.j2 +7 -7
- nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +4 -4
- nuitka/code_generation/templates_c/HelperSlotsBinary.c.j2 +1 -1
- nuitka/code_generation/templates_c/HelperSlotsInt.c.j2 +31 -31
- nuitka/code_generation/templates_c/HelperSlotsLong.c.j2 +1 -1
- nuitka/containers/Namedtuples.py +6 -0
- nuitka/containers/OrderedSets.py +105 -5
- nuitka/distutils/Build.py +14 -0
- nuitka/distutils/DistutilCommands.py +50 -10
- nuitka/finalizations/Finalization.py +3 -3
- nuitka/finalizations/FinalizeMarkups.py +10 -14
- nuitka/freezer/DependsExe.py +5 -2
- nuitka/freezer/DllDependenciesMacOS.py +18 -1
- nuitka/freezer/DllDependenciesWin32.py +26 -12
- nuitka/freezer/ImportDetection.py +6 -0
- nuitka/freezer/IncludedDataFiles.py +37 -6
- nuitka/freezer/Onefile.py +1 -0
- nuitka/freezer/Standalone.py +72 -18
- nuitka/importing/Importing.py +33 -6
- nuitka/importing/Recursion.py +5 -2
- nuitka/importing/StandardLibrary.py +57 -59
- nuitka/nodes/AsyncgenNodes.py +3 -6
- nuitka/nodes/BuiltinIteratorNodes.py +2 -2
- nuitka/nodes/BuiltinRefNodes.py +14 -30
- nuitka/nodes/ChildrenHavingMixins.py +439 -46
- nuitka/nodes/ConditionalNodes.py +3 -2
- nuitka/nodes/CoroutineNodes.py +3 -6
- nuitka/nodes/DictionaryNodes.py +1 -1
- nuitka/nodes/ExceptionNodes.py +102 -26
- nuitka/nodes/ExpressionBasesGenerated.py +288 -4
- nuitka/nodes/FrameNodes.py +22 -11
- nuitka/nodes/FunctionNodes.py +3 -3
- nuitka/nodes/GeneratorNodes.py +3 -6
- nuitka/nodes/HardImportNodesGenerated.py +182 -0
- nuitka/nodes/ImportNodes.py +2 -2
- nuitka/nodes/NodeBases.py +28 -1
- nuitka/nodes/NodeMakingHelpers.py +71 -50
- nuitka/nodes/OperatorNodesUnary.py +128 -3
- nuitka/nodes/OsSysNodes.py +37 -6
- nuitka/nodes/OutlineNodes.py +2 -2
- nuitka/nodes/StatementBasesGenerated.py +0 -2
- nuitka/nodes/StatementNodes.py +8 -7
- nuitka/nodes/SubscriptNodes.py +1 -1
- nuitka/nodes/TypeNodes.py +28 -1
- nuitka/nodes/VariableAssignNodes.py +2 -1
- nuitka/nodes/shapes/BuiltinTypeShapes.py +24 -7
- nuitka/nodes/shapes/IteratorShapes.py +71 -0
- nuitka/nodes/shapes/ShapeMixins.py +18 -0
- nuitka/nodes/shapes/StandardShapes.py +47 -44
- nuitka/optimizations/BytecodeDemotion.py +2 -1
- nuitka/plugins/PluginBase.py +64 -22
- nuitka/plugins/Plugins.py +16 -3
- nuitka/plugins/standard/AntiBloatPlugin.py +23 -12
- nuitka/plugins/standard/DllFilesPlugin.py +78 -2
- nuitka/plugins/standard/ImplicitImports.py +5 -15
- nuitka/plugins/standard/KivyPlugin.py +3 -12
- nuitka/plugins/standard/MatplotlibPlugin.py +12 -1
- nuitka/plugins/standard/MultiprocessingPlugin.py +11 -20
- nuitka/plugins/standard/OptionsNannyPlugin.py +5 -4
- nuitka/plugins/standard/PlaywrightPlugin.py +184 -0
- nuitka/plugins/standard/PySidePyQtPlugin.py +8 -0
- nuitka/plugins/standard/TkinterPlugin.py +23 -3
- nuitka/plugins/standard/TransformersPlugin.py +70 -275
- nuitka/plugins/standard/standard.nuitka-package.config.yml +413 -30
- nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +35 -2
- nuitka/reports/CompilationReportReader.py +12 -0
- nuitka/reports/Reports.py +11 -0
- nuitka/specs/BuiltinParameterSpecs.py +5 -1
- nuitka/specs/HardImportSpecs.py +7 -0
- nuitka/specs/ParameterSpecs.py +4 -4
- nuitka/tools/environments/Virtualenv.py +13 -5
- nuitka/tools/general/dll_report/__main__.py +10 -1
- nuitka/tools/onefile_compressor/OnefileCompressor.py +1 -1
- nuitka/tools/podman/__main__.py +4 -2
- nuitka/tools/specialize/CTypeDescriptions.py +158 -9
- nuitka/tools/specialize/SpecializeC.py +218 -56
- nuitka/tools/testing/Common.py +69 -62
- nuitka/tools/testing/compare_with_cpython/__main__.py +3 -1
- nuitka/tools/testing/measure_construct_performance/__main__.py +1 -8
- nuitka/tools/testing/run_nuitka_tests/__main__.py +77 -11
- nuitka/tools/watch/AutoStage.py +1 -0
- nuitka/tree/Building.py +10 -37
- nuitka/tree/ComplexCallHelperFunctions.py +4 -0
- nuitka/tree/ReformulationAssertStatements.py +31 -14
- nuitka/tree/ReformulationAssignmentStatements.py +5 -1
- nuitka/tree/ReformulationClasses3.py +94 -19
- nuitka/tree/ReformulationDictionaryCreation.py +1 -0
- nuitka/tree/ReformulationFunctionStatements.py +1 -1
- nuitka/tree/ReformulationMatchStatements.py +3 -1
- nuitka/tree/ReformulationYieldExpressions.py +23 -5
- nuitka/utils/CommandLineOptions.py +27 -3
- nuitka/utils/Download.py +2 -2
- nuitka/utils/Execution.py +36 -31
- nuitka/utils/FileOperations.py +18 -39
- nuitka/utils/Hashing.py +5 -1
- nuitka/utils/Importing.py +2 -14
- nuitka/utils/InlineCopies.py +52 -0
- nuitka/utils/InstalledPythons.py +9 -4
- nuitka/utils/Json.py +2 -2
- nuitka/utils/PackageResources.py +44 -0
- nuitka/utils/SharedLibraries.py +24 -0
- nuitka/utils/Signing.py +9 -1
- nuitka/utils/Utils.py +1 -0
- {Nuitka_winsvc-2.4.11.data → Nuitka_winsvc-2.5.6.data}/scripts/nuitka-run.cmd +0 -0
- {Nuitka_winsvc-2.4.11.data → Nuitka_winsvc-2.5.6.data}/scripts/nuitka.cmd +0 -0
- {Nuitka_winsvc-2.4.11.dist-info → Nuitka_winsvc-2.5.6.dist-info}/LICENSE.txt +0 -0
- {Nuitka_winsvc-2.4.11.dist-info → Nuitka_winsvc-2.5.6.dist-info}/entry_points.txt +0 -0
- {Nuitka_winsvc-2.4.11.dist-info → Nuitka_winsvc-2.5.6.dist-info}/top_level.txt +0 -0
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
#include <structmember.h>
|
|
16
16
|
#endif
|
|
17
17
|
|
|
18
|
-
static PyObject *Nuitka_Method_get__doc__(
|
|
18
|
+
static PyObject *Nuitka_Method_get__doc__(PyObject *self, void *data) {
|
|
19
|
+
struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)self;
|
|
19
20
|
PyObject *result = method->m_function->m_doc;
|
|
20
21
|
|
|
21
22
|
if (result == NULL) {
|
|
@@ -26,8 +27,7 @@ static PyObject *Nuitka_Method_get__doc__(struct Nuitka_MethodObject *method, vo
|
|
|
26
27
|
return result;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
static PyGetSetDef Nuitka_Method_tp_getset[] = {{(char *)"__doc__",
|
|
30
|
-
{NULL}};
|
|
30
|
+
static PyGetSetDef Nuitka_Method_tp_getset[] = {{(char *)"__doc__", Nuitka_Method_get__doc__, NULL, NULL}, {NULL}};
|
|
31
31
|
|
|
32
32
|
#define OFF(x) offsetof(struct Nuitka_MethodObject, x)
|
|
33
33
|
|
|
@@ -43,16 +43,13 @@ static PyMemberDef Nuitka_Method_members[] = {
|
|
|
43
43
|
(char *)"the instance to which a method is bound; None for unbound method"},
|
|
44
44
|
{NULL}};
|
|
45
45
|
|
|
46
|
-
static PyObject *Nuitka_Method_reduce(struct Nuitka_MethodObject *method) {
|
|
46
|
+
static PyObject *Nuitka_Method_reduce(struct Nuitka_MethodObject *method, PyObject *unused) {
|
|
47
47
|
PyThreadState *tstate = PyThreadState_GET();
|
|
48
48
|
|
|
49
49
|
#if PYTHON_VERSION < 0x300
|
|
50
50
|
// spell-checker: ignore instancemethod
|
|
51
51
|
SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "can't pickle instancemethod objects");
|
|
52
52
|
return NULL;
|
|
53
|
-
#elif PYTHON_VERSION < 0x340
|
|
54
|
-
SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "can't pickle method objects");
|
|
55
|
-
return NULL;
|
|
56
53
|
#else
|
|
57
54
|
PyObject *result = MAKE_TUPLE_EMPTY(tstate, 2);
|
|
58
55
|
PyTuple_SET_ITEM0(result, 0, LOOKUP_BUILTIN(const_str_plain_getattr));
|
|
@@ -74,12 +71,9 @@ static PyObject *Nuitka_Method_reduce_ex(struct Nuitka_MethodObject *method, PyO
|
|
|
74
71
|
|
|
75
72
|
// Python API, spell-checker: ignore copyreg,newobj
|
|
76
73
|
|
|
77
|
-
#if PYTHON_VERSION < 0x340
|
|
78
74
|
#if PYTHON_VERSION < 0x300
|
|
79
75
|
PyObject *copy_reg = PyImport_ImportModule("copy_reg");
|
|
80
|
-
|
|
81
|
-
PyObject *copy_reg = PyImport_ImportModule("copyreg");
|
|
82
|
-
#endif
|
|
76
|
+
|
|
83
77
|
CHECK_OBJECT(copy_reg);
|
|
84
78
|
PyThreadState *tstate = PyThreadState_GET();
|
|
85
79
|
|
|
@@ -101,7 +95,7 @@ static PyObject *Nuitka_Method_reduce_ex(struct Nuitka_MethodObject *method, PyO
|
|
|
101
95
|
|
|
102
96
|
return result;
|
|
103
97
|
#else
|
|
104
|
-
return Nuitka_Method_reduce(method);
|
|
98
|
+
return Nuitka_Method_reduce(method, NULL);
|
|
105
99
|
#endif
|
|
106
100
|
}
|
|
107
101
|
|
|
@@ -8,9 +8,18 @@
|
|
|
8
8
|
#include "nuitka/prelude.h"
|
|
9
9
|
#endif
|
|
10
10
|
|
|
11
|
+
// spell-checker: ignore PYMEM_DOMAIN,Nuitka_gc_decref,gcstate,uncollectable,sisnsn,QSBR,wrasgc
|
|
12
|
+
// spell-checker: ignore Nuitka_visit_decref,finalizers,wrcb,wrlist,_PyObject_GET_WEAKREFS_LISTPTR
|
|
13
|
+
// spell-checker: ignore objmalloc,qbsr,stoptheworld
|
|
14
|
+
|
|
11
15
|
void *(*python_obj_malloc)(void *ctx, size_t size) = NULL;
|
|
12
16
|
void *(*python_mem_malloc)(void *ctx, size_t size) = NULL;
|
|
13
17
|
void *(*python_mem_calloc)(void *ctx, size_t nelem, size_t elsize) = NULL;
|
|
18
|
+
#ifndef Py_GIL_DISABLED
|
|
19
|
+
void *(*python_mem_realloc)(void *ctx, void *ptr, size_t new_size) = NULL;
|
|
20
|
+
#else
|
|
21
|
+
void (*python_mem_free)(void *ctx, void *ptr) = NULL;
|
|
22
|
+
#endif
|
|
14
23
|
|
|
15
24
|
#if defined(Py_DEBUG)
|
|
16
25
|
void *python_obj_ctx = NULL;
|
|
@@ -18,8 +27,6 @@ void *python_mem_ctx = NULL;
|
|
|
18
27
|
#endif
|
|
19
28
|
|
|
20
29
|
void initNuitkaAllocators(void) {
|
|
21
|
-
// PyMem_SetupDebugHooks();
|
|
22
|
-
|
|
23
30
|
PyMemAllocatorEx allocators;
|
|
24
31
|
|
|
25
32
|
PyMem_GetAllocator(PYMEM_DOMAIN_OBJ, &allocators);
|
|
@@ -38,6 +45,11 @@ void initNuitkaAllocators(void) {
|
|
|
38
45
|
|
|
39
46
|
python_mem_malloc = allocators.malloc;
|
|
40
47
|
python_mem_calloc = allocators.calloc;
|
|
48
|
+
#ifndef Py_GIL_DISABLED
|
|
49
|
+
python_mem_realloc = allocators.realloc;
|
|
50
|
+
#else
|
|
51
|
+
python_mem_free = allocators.free;
|
|
52
|
+
#endif
|
|
41
53
|
}
|
|
42
54
|
|
|
43
55
|
#if PYTHON_VERSION >= 0x3b0
|
|
@@ -306,7 +318,7 @@ static void Nuitka_gc_list_move(PyGC_Head *node, PyGC_Head *list) {
|
|
|
306
318
|
_PyGCHead_SET_NEXT(node, list);
|
|
307
319
|
}
|
|
308
320
|
|
|
309
|
-
static void
|
|
321
|
+
static void _Nuitka_move_legacy_finalizers(PyGC_Head *unreachable, PyGC_Head *finalizers) {
|
|
310
322
|
PyGC_Head *next;
|
|
311
323
|
for (PyGC_Head *gc = GC_NEXT(unreachable); gc != unreachable; gc = next) {
|
|
312
324
|
PyObject *op = FROM_GC(gc);
|
|
@@ -322,11 +334,11 @@ static void Nuitka_move_legacy_finalizers(PyGC_Head *unreachable, PyGC_Head *fin
|
|
|
322
334
|
}
|
|
323
335
|
}
|
|
324
336
|
|
|
325
|
-
static int
|
|
337
|
+
static int _Nuitka_visit_move(PyObject *op, PyGC_Head *to_list) {
|
|
326
338
|
if (_PyObject_IS_GC(op)) {
|
|
327
339
|
PyGC_Head *gc = AS_GC(op);
|
|
328
340
|
if (Nuitka_gc_is_collecting(gc)) {
|
|
329
|
-
Nuitka_gc_list_move(gc,
|
|
341
|
+
Nuitka_gc_list_move(gc, to_list);
|
|
330
342
|
Nuitka_gc_clear_collecting(gc);
|
|
331
343
|
}
|
|
332
344
|
}
|
|
@@ -338,7 +350,7 @@ static int Nuitka_visit_move(PyObject *op, PyGC_Head *tolist) {
|
|
|
338
350
|
static void Nuitka_move_legacy_finalizer_reachable(PyGC_Head *finalizers) {
|
|
339
351
|
for (PyGC_Head *gc = GC_NEXT(finalizers); gc != finalizers; gc = GC_NEXT(gc)) {
|
|
340
352
|
traverseproc traverse = Py_TYPE(FROM_GC(gc))->tp_traverse;
|
|
341
|
-
(void)traverse(FROM_GC(gc), (visitproc)
|
|
353
|
+
(void)traverse(FROM_GC(gc), (visitproc)_Nuitka_visit_move, (void *)finalizers);
|
|
342
354
|
}
|
|
343
355
|
}
|
|
344
356
|
|
|
@@ -350,15 +362,15 @@ static void Nuitka_finalize_garbage(PyThreadState *tstate, PyGC_Head *collectabl
|
|
|
350
362
|
|
|
351
363
|
while (Nuitka_gc_list_is_empty(collectable) == false) {
|
|
352
364
|
PyGC_Head *gc = GC_NEXT(collectable);
|
|
353
|
-
PyObject *
|
|
365
|
+
PyObject *object = FROM_GC(gc);
|
|
354
366
|
Nuitka_gc_list_move(gc, &seen);
|
|
355
367
|
|
|
356
|
-
if (!_PyGCHead_FINALIZED(gc) && (finalize = Py_TYPE(
|
|
368
|
+
if (!_PyGCHead_FINALIZED(gc) && (finalize = Py_TYPE(object)->tp_finalize) != NULL) {
|
|
357
369
|
_PyGCHead_SET_FINALIZED(gc);
|
|
358
|
-
Py_INCREF(
|
|
359
|
-
finalize(
|
|
370
|
+
Py_INCREF(object);
|
|
371
|
+
finalize(object);
|
|
360
372
|
assert(!HAS_ERROR_OCCURRED(tstate));
|
|
361
|
-
Py_DECREF(
|
|
373
|
+
Py_DECREF(object);
|
|
362
374
|
}
|
|
363
375
|
}
|
|
364
376
|
Nuitka_gc_list_merge(&seen, collectable);
|
|
@@ -366,7 +378,7 @@ static void Nuitka_finalize_garbage(PyThreadState *tstate, PyGC_Head *collectabl
|
|
|
366
378
|
|
|
367
379
|
static int Nuitka_handle_weakrefs(PyThreadState *tstate, PyGC_Head *unreachable, PyGC_Head *old) {
|
|
368
380
|
PyGC_Head *gc;
|
|
369
|
-
PyObject *
|
|
381
|
+
PyObject *object;
|
|
370
382
|
PyWeakReference *wr;
|
|
371
383
|
PyGC_Head wrcb_to_call;
|
|
372
384
|
PyGC_Head *next;
|
|
@@ -377,17 +389,17 @@ static int Nuitka_handle_weakrefs(PyThreadState *tstate, PyGC_Head *unreachable,
|
|
|
377
389
|
for (gc = GC_NEXT(unreachable); gc != unreachable; gc = next) {
|
|
378
390
|
PyWeakReference **wrlist;
|
|
379
391
|
|
|
380
|
-
|
|
392
|
+
object = FROM_GC(gc);
|
|
381
393
|
next = GC_NEXT(gc);
|
|
382
394
|
|
|
383
|
-
if (PyWeakref_Check(
|
|
384
|
-
_PyWeakref_ClearRef((PyWeakReference *)
|
|
395
|
+
if (PyWeakref_Check(object)) {
|
|
396
|
+
_PyWeakref_ClearRef((PyWeakReference *)object);
|
|
385
397
|
}
|
|
386
398
|
|
|
387
|
-
if (!_PyType_SUPPORTS_WEAKREFS(Py_TYPE(
|
|
399
|
+
if (!_PyType_SUPPORTS_WEAKREFS(Py_TYPE(object)))
|
|
388
400
|
continue;
|
|
389
401
|
|
|
390
|
-
wrlist = (PyWeakReference **)_PyObject_GET_WEAKREFS_LISTPTR(
|
|
402
|
+
wrlist = (PyWeakReference **)_PyObject_GET_WEAKREFS_LISTPTR(object);
|
|
391
403
|
|
|
392
404
|
for (wr = *wrlist; wr != NULL; wr = *wrlist) {
|
|
393
405
|
PyGC_Head *wrasgc;
|
|
@@ -414,8 +426,8 @@ static int Nuitka_handle_weakrefs(PyThreadState *tstate, PyGC_Head *unreachable,
|
|
|
414
426
|
PyObject *callback;
|
|
415
427
|
|
|
416
428
|
gc = (PyGC_Head *)wrcb_to_call._gc_next;
|
|
417
|
-
|
|
418
|
-
wr = (PyWeakReference *)
|
|
429
|
+
object = FROM_GC(gc);
|
|
430
|
+
wr = (PyWeakReference *)object;
|
|
419
431
|
callback = wr->wr_callback;
|
|
420
432
|
|
|
421
433
|
temp = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, callback, (PyObject *)wr);
|
|
@@ -424,7 +436,7 @@ static int Nuitka_handle_weakrefs(PyThreadState *tstate, PyGC_Head *unreachable,
|
|
|
424
436
|
else
|
|
425
437
|
Py_DECREF(temp);
|
|
426
438
|
|
|
427
|
-
Py_DECREF(
|
|
439
|
+
Py_DECREF(object);
|
|
428
440
|
if (wrcb_to_call._gc_next == (uintptr_t)gc) {
|
|
429
441
|
Nuitka_gc_list_move(gc, old);
|
|
430
442
|
} else {
|
|
@@ -466,19 +478,19 @@ static void Nuitka_delete_garbage(PyThreadState *tstate, GCState *gcstate, PyGC_
|
|
|
466
478
|
|
|
467
479
|
while (Nuitka_gc_list_is_empty(collectable) == false) {
|
|
468
480
|
PyGC_Head *gc = GC_NEXT(collectable);
|
|
469
|
-
PyObject *
|
|
481
|
+
PyObject *object = FROM_GC(gc);
|
|
470
482
|
|
|
471
|
-
_PyObject_ASSERT_WITH_MSG(
|
|
483
|
+
_PyObject_ASSERT_WITH_MSG(object, Py_REFCNT(object) > 0, "refcount is too small");
|
|
472
484
|
|
|
473
485
|
{
|
|
474
486
|
inquiry clear;
|
|
475
|
-
if ((clear = Py_TYPE(
|
|
476
|
-
Py_INCREF(
|
|
477
|
-
(void)clear(
|
|
487
|
+
if ((clear = Py_TYPE(object)->tp_clear) != NULL) {
|
|
488
|
+
Py_INCREF(object);
|
|
489
|
+
(void)clear(object);
|
|
478
490
|
if (HAS_ERROR_OCCURRED(tstate)) {
|
|
479
|
-
_PyErr_WriteUnraisableMsg("in tp_clear of", (PyObject *)Py_TYPE(
|
|
491
|
+
_PyErr_WriteUnraisableMsg("in tp_clear of", (PyObject *)Py_TYPE(object));
|
|
480
492
|
}
|
|
481
|
-
Py_DECREF(
|
|
493
|
+
Py_DECREF(object);
|
|
482
494
|
}
|
|
483
495
|
}
|
|
484
496
|
if (GC_NEXT(collectable) == gc) {
|
|
@@ -560,7 +572,7 @@ static Py_ssize_t Nuitka_gc_collect_main(PyThreadState *tstate, int generation,
|
|
|
560
572
|
|
|
561
573
|
Nuitka_gc_list_init(&finalizers);
|
|
562
574
|
|
|
563
|
-
|
|
575
|
+
_Nuitka_move_legacy_finalizers(&unreachable, &finalizers);
|
|
564
576
|
|
|
565
577
|
Nuitka_move_legacy_finalizer_reachable(&finalizers);
|
|
566
578
|
|
|
@@ -685,6 +697,232 @@ void Nuitka_PyObject_GC_Link(PyObject *op) {
|
|
|
685
697
|
|
|
686
698
|
#endif
|
|
687
699
|
|
|
700
|
+
#ifdef Py_GIL_DISABLED
|
|
701
|
+
|
|
702
|
+
// Needs to align with CPython "objmalloc.c"
|
|
703
|
+
#define WORK_ITEMS_PER_CHUNK 254
|
|
704
|
+
struct _mem_work_item {
|
|
705
|
+
uintptr_t ptr; // lowest bit tagged 1 for objects freed with PyObject_Free
|
|
706
|
+
uint64_t qsbr_goal;
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
struct _mem_work_chunk {
|
|
710
|
+
struct llist_node node;
|
|
711
|
+
|
|
712
|
+
Py_ssize_t rd_idx; // index of next item to read
|
|
713
|
+
Py_ssize_t wr_idx; // index of next item to write
|
|
714
|
+
struct _mem_work_item array[WORK_ITEMS_PER_CHUNK];
|
|
715
|
+
};
|
|
716
|
+
|
|
717
|
+
// Aligns with CPython "qsbr.c"
|
|
718
|
+
#define QSBR_DEFERRED_LIMIT 10
|
|
719
|
+
|
|
720
|
+
static uint64_t Nuitka_qsbr_advance(struct _qsbr_shared *shared) {
|
|
721
|
+
return _Py_atomic_add_uint64(&shared->wr_seq, QSBR_INCR) + QSBR_INCR;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
static uint64_t Nuitka_qsbr_deferred_advance(struct _qsbr_thread_state *qsbr) {
|
|
725
|
+
if (++qsbr->deferrals < QSBR_DEFERRED_LIMIT) {
|
|
726
|
+
return _Py_qsbr_shared_current(qsbr->shared) + QSBR_INCR;
|
|
727
|
+
}
|
|
728
|
+
qsbr->deferrals = 0;
|
|
729
|
+
return Nuitka_qsbr_advance(qsbr->shared);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
static uint64_t _Nuitka_qsbr_poll_scan(struct _qsbr_shared *shared) {
|
|
733
|
+
_Py_atomic_fence_seq_cst();
|
|
734
|
+
|
|
735
|
+
uint64_t min_seq = _Py_atomic_load_uint64(&shared->wr_seq);
|
|
736
|
+
struct _qsbr_pad *array = shared->array;
|
|
737
|
+
for (Py_ssize_t i = 0, size = shared->size; i != size; i++) {
|
|
738
|
+
struct _qsbr_thread_state *qsbr = &array[i].qsbr;
|
|
739
|
+
|
|
740
|
+
uint64_t seq = _Py_atomic_load_uint64(&qsbr->seq);
|
|
741
|
+
if (seq != QSBR_OFFLINE && QSBR_LT(seq, min_seq)) {
|
|
742
|
+
min_seq = seq;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
uint64_t rd_seq = _Py_atomic_load_uint64(&shared->rd_seq);
|
|
747
|
+
if (QSBR_LT(rd_seq, min_seq)) {
|
|
748
|
+
(void)_Py_atomic_compare_exchange_uint64(&shared->rd_seq, &rd_seq, min_seq);
|
|
749
|
+
rd_seq = min_seq;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
return rd_seq;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
static bool _Nuitka_qsbr_poll(struct _qsbr_thread_state *qsbr, uint64_t goal) {
|
|
756
|
+
assert(_Py_atomic_load_int_relaxed(&_PyThreadState_GET()->state) == _Py_THREAD_ATTACHED);
|
|
757
|
+
|
|
758
|
+
if (_Py_qbsr_goal_reached(qsbr, goal)) {
|
|
759
|
+
return true;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
uint64_t rd_seq = _Nuitka_qsbr_poll_scan(qsbr->shared);
|
|
763
|
+
return QSBR_LEQ(goal, rd_seq);
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
static void _NuitkaMem_free_work_item(uintptr_t ptr) {
|
|
767
|
+
if (ptr & 0x01) {
|
|
768
|
+
PyObject_Free((char *)(ptr - 1));
|
|
769
|
+
} else {
|
|
770
|
+
NuitkaMem_Free((void *)ptr);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
static struct _mem_work_chunk *work_queue_first(struct llist_node *head) {
|
|
775
|
+
return llist_data(head->next, struct _mem_work_chunk, node);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
static void _Nuitka_process_queue(struct llist_node *head, struct _qsbr_thread_state *qsbr, bool keep_empty) {
|
|
779
|
+
while (!llist_empty(head)) {
|
|
780
|
+
struct _mem_work_chunk *buf = work_queue_first(head);
|
|
781
|
+
|
|
782
|
+
while (buf->rd_idx < buf->wr_idx) {
|
|
783
|
+
struct _mem_work_item *item = &buf->array[buf->rd_idx];
|
|
784
|
+
if (!_Nuitka_qsbr_poll(qsbr, item->qsbr_goal)) {
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
_NuitkaMem_free_work_item(item->ptr);
|
|
789
|
+
buf->rd_idx++;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
assert(buf->rd_idx == buf->wr_idx);
|
|
793
|
+
|
|
794
|
+
if (keep_empty && buf->node.next == head) {
|
|
795
|
+
// Keeping the last buffer as a free-list entry.
|
|
796
|
+
buf->rd_idx = buf->wr_idx = 0;
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
llist_remove(&buf->node);
|
|
801
|
+
NuitkaMem_Free(buf);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
struct mutex_entry {
|
|
806
|
+
// The time after which the unlocking thread should hand off lock ownership
|
|
807
|
+
// directly to the waiting thread. Written by the waiting thread.
|
|
808
|
+
PyTime_t time_to_be_fair;
|
|
809
|
+
|
|
810
|
+
// Set to 1 if the lock was handed off. Written by the unlocking thread.
|
|
811
|
+
int handed_off;
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
static const PyTime_t TIME_TO_BE_FAIR_NS = 1000 * 1000;
|
|
815
|
+
static const int MAX_SPIN_COUNT = 40;
|
|
816
|
+
|
|
817
|
+
static void _Nuitka_yield(void) {
|
|
818
|
+
#ifdef _WIN32
|
|
819
|
+
SwitchToThread();
|
|
820
|
+
#else
|
|
821
|
+
sched_yield();
|
|
822
|
+
#endif
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
PyLockStatus _NuitkaMutex_LockTimed(PyMutex *m) {
|
|
826
|
+
uint8_t v = _Py_atomic_load_uint8_relaxed(&m->_bits);
|
|
827
|
+
if ((v & _Py_LOCKED) == 0) {
|
|
828
|
+
if (_Py_atomic_compare_exchange_uint8(&m->_bits, &v, v | _Py_LOCKED)) {
|
|
829
|
+
return PY_LOCK_ACQUIRED;
|
|
830
|
+
}
|
|
831
|
+
} else {
|
|
832
|
+
return PY_LOCK_FAILURE;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
Py_ssize_t spin_count = 0;
|
|
836
|
+
|
|
837
|
+
for (;;) {
|
|
838
|
+
if ((v & _Py_LOCKED) == 0) {
|
|
839
|
+
if (_Py_atomic_compare_exchange_uint8(&m->_bits, &v, v | _Py_LOCKED)) {
|
|
840
|
+
return PY_LOCK_ACQUIRED;
|
|
841
|
+
}
|
|
842
|
+
continue;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
if (!(v & _Py_HAS_PARKED) && spin_count < MAX_SPIN_COUNT) {
|
|
846
|
+
// Spin for a bit.
|
|
847
|
+
_Nuitka_yield();
|
|
848
|
+
|
|
849
|
+
spin_count++;
|
|
850
|
+
continue;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
return PY_LOCK_FAILURE;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
static void _Nuitka_process_interp_queue(struct _Py_mem_interp_free_queue *queue, struct _qsbr_thread_state *qsbr) {
|
|
858
|
+
if (!_Py_atomic_load_int_relaxed(&queue->has_work)) {
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
// Try to acquire the lock, but don't block if it's already held.
|
|
863
|
+
if (_NuitkaMutex_LockTimed(&queue->mutex) == PY_LOCK_ACQUIRED) {
|
|
864
|
+
_Nuitka_process_queue(&queue->head, qsbr, false);
|
|
865
|
+
|
|
866
|
+
int more_work = !llist_empty(&queue->head);
|
|
867
|
+
_Py_atomic_store_int_relaxed(&queue->has_work, more_work);
|
|
868
|
+
|
|
869
|
+
PyMutex_Unlock(&queue->mutex);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
void _NuitkaMem_ProcessDelayed(PyThreadState *tstate) {
|
|
874
|
+
PyInterpreterState *interp = tstate->interp;
|
|
875
|
+
_PyThreadStateImpl *tstate_impl = (_PyThreadStateImpl *)tstate;
|
|
876
|
+
|
|
877
|
+
// Release thread-local queue
|
|
878
|
+
_Nuitka_process_queue(&tstate_impl->mem_free_queue, tstate_impl->qsbr, true);
|
|
879
|
+
|
|
880
|
+
// Release interpreter queue
|
|
881
|
+
_Nuitka_process_interp_queue(&interp->mem_free_queue, tstate_impl->qsbr);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
static void _NuitkaMem_FreeDelayed2(uintptr_t ptr) {
|
|
885
|
+
// Free immediately if possible.
|
|
886
|
+
if (_PyRuntime.stoptheworld.world_stopped) {
|
|
887
|
+
_NuitkaMem_free_work_item(ptr);
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// Allocate an entry for later processing.
|
|
892
|
+
_PyThreadStateImpl *tstate = (_PyThreadStateImpl *)_PyThreadState_GET();
|
|
893
|
+
struct llist_node *head = &tstate->mem_free_queue;
|
|
894
|
+
|
|
895
|
+
struct _mem_work_chunk *buf = NULL;
|
|
896
|
+
if (!llist_empty(head)) {
|
|
897
|
+
// Try to reuse the last buffer
|
|
898
|
+
buf = llist_data(head->prev, struct _mem_work_chunk, node);
|
|
899
|
+
if (buf->wr_idx == WORK_ITEMS_PER_CHUNK) {
|
|
900
|
+
// already full
|
|
901
|
+
buf = NULL;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
if (buf == NULL) {
|
|
906
|
+
buf = NuitkaMem_Calloc(1, sizeof(*buf));
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
assert(buf != NULL && buf->wr_idx < WORK_ITEMS_PER_CHUNK);
|
|
910
|
+
uint64_t seq = Nuitka_qsbr_deferred_advance(tstate->qsbr);
|
|
911
|
+
buf->array[buf->wr_idx].ptr = ptr;
|
|
912
|
+
buf->array[buf->wr_idx].qsbr_goal = seq;
|
|
913
|
+
buf->wr_idx++;
|
|
914
|
+
|
|
915
|
+
if (buf->wr_idx == WORK_ITEMS_PER_CHUNK) {
|
|
916
|
+
_NuitkaMem_ProcessDelayed((PyThreadState *)tstate);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
void NuitkaMem_FreeDelayed(void *ptr) {
|
|
921
|
+
assert(!((uintptr_t)ptr & 0x01));
|
|
922
|
+
_NuitkaMem_FreeDelayed2((uintptr_t)ptr);
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
#endif
|
|
688
926
|
// Part of "Nuitka", an optimizing Python compiler that is compatible and
|
|
689
927
|
// integrates with CPython, but also works on its own.
|
|
690
928
|
//
|
|
@@ -1222,27 +1222,6 @@ PyObject *LOOKUP_MODULE_VALUE(PyDictObject *module_dict, PyObject *var_name) {
|
|
|
1222
1222
|
return result;
|
|
1223
1223
|
}
|
|
1224
1224
|
|
|
1225
|
-
PyObject *GET_MODULE_VARIABLE_VALUE_FALLBACK(PyThreadState *tstate, PyObject *variable_name) {
|
|
1226
|
-
PyObject *result = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)variable_name);
|
|
1227
|
-
|
|
1228
|
-
if (unlikely(result == NULL)) {
|
|
1229
|
-
SET_CURRENT_EXCEPTION_NAME_ERROR(tstate, variable_name);
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
return result;
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
#if PYTHON_VERSION < 0x340
|
|
1236
|
-
PyObject *GET_MODULE_VARIABLE_VALUE_FALLBACK_IN_FUNCTION(PyThreadState *tstate, PyObject *variable_name) {
|
|
1237
|
-
PyObject *result = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)variable_name);
|
|
1238
|
-
|
|
1239
|
-
if (unlikely(result == NULL)) {
|
|
1240
|
-
SET_CURRENT_EXCEPTION_GLOBAL_NAME_ERROR(tstate, variable_name);
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
return result;
|
|
1244
|
-
}
|
|
1245
|
-
#endif
|
|
1246
1225
|
// Part of "Nuitka", an optimizing Python compiler that is compatible and
|
|
1247
1226
|
// integrates with CPython, but also works on its own.
|
|
1248
1227
|
//
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
#endif
|
|
17
17
|
|
|
18
18
|
PyObject *CALL_BUILTIN_KW_ARGS(PyThreadState *tstate, PyObject *callable, PyObject **args, char const **arg_names,
|
|
19
|
-
int max_args) {
|
|
19
|
+
int max_args, int kw_only_args) {
|
|
20
20
|
int i = 0;
|
|
21
21
|
|
|
22
|
-
while (i < max_args) {
|
|
22
|
+
while (i < max_args - kw_only_args) {
|
|
23
23
|
if (args[i] == NULL) {
|
|
24
24
|
break;
|
|
25
25
|
}
|
|
@@ -48,7 +48,7 @@ PyObject *CALL_BUILTIN_KW_ARGS(PyThreadState *tstate, PyObject *callable, PyObje
|
|
|
48
48
|
i++;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
PyObject *args_tuple =
|
|
51
|
+
PyObject *args_tuple = MAKE_TUPLE_VAR(tstate, args, usable_args);
|
|
52
52
|
|
|
53
53
|
PyObject *result = CALL_FUNCTION(tstate, callable, args_tuple, kw_dict);
|
|
54
54
|
Py_XDECREF(kw_dict);
|
|
@@ -225,7 +225,7 @@ PyObject *BUILTIN_OPEN(PyThreadState *tstate, PyObject *file_name, PyObject *mod
|
|
|
225
225
|
|
|
226
226
|
char const *arg_names[] = {"name", "mode", "buffering"};
|
|
227
227
|
|
|
228
|
-
return CALL_BUILTIN_KW_ARGS(tstate, NUITKA_ACCESS_BUILTIN(open), args, arg_names, 3);
|
|
228
|
+
return CALL_BUILTIN_KW_ARGS(tstate, NUITKA_ACCESS_BUILTIN(open), args, arg_names, 3, 0);
|
|
229
229
|
}
|
|
230
230
|
#else
|
|
231
231
|
PyObject *BUILTIN_OPEN(PyThreadState *tstate, PyObject *file_name, PyObject *mode, PyObject *buffering,
|
|
@@ -242,7 +242,7 @@ PyObject *BUILTIN_OPEN(PyThreadState *tstate, PyObject *file_name, PyObject *mod
|
|
|
242
242
|
|
|
243
243
|
char const *arg_names[] = {"file", "mode", "buffering", "encoding", "errors", "newline", "closefd", "opener"};
|
|
244
244
|
|
|
245
|
-
return CALL_BUILTIN_KW_ARGS(tstate, NUITKA_ACCESS_BUILTIN(open), args, arg_names, 8);
|
|
245
|
+
return CALL_BUILTIN_KW_ARGS(tstate, NUITKA_ACCESS_BUILTIN(open), args, arg_names, 8, 0);
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
#endif
|
|
@@ -315,7 +315,7 @@ PyObject *BUILTIN_BYTES3(PyThreadState *tstate, PyObject *value, PyObject *encod
|
|
|
315
315
|
|
|
316
316
|
char const *arg_names[] = {"value", "encoding", "errors"};
|
|
317
317
|
|
|
318
|
-
return CALL_BUILTIN_KW_ARGS(tstate, NUITKA_ACCESS_BUILTIN(bytes), args, arg_names, 3);
|
|
318
|
+
return CALL_BUILTIN_KW_ARGS(tstate, NUITKA_ACCESS_BUILTIN(bytes), args, arg_names, 3, 0);
|
|
319
319
|
}
|
|
320
320
|
#endif
|
|
321
321
|
|
|
@@ -422,6 +422,7 @@ PyObject *BUILTIN_HEX(PyThreadState *tstate, PyObject *value) {
|
|
|
422
422
|
|
|
423
423
|
static void SET_HASH_NOT_IMPLEMENTED_ERROR(PyThreadState *tstate, PyObject *value) {
|
|
424
424
|
// TODO: Use our own formatting code.
|
|
425
|
+
// spell-checker: ignore unhashable
|
|
425
426
|
|
|
426
427
|
PyErr_Format(PyExc_TypeError, "unhashable type: '%s'", Py_TYPE(value)->tp_name);
|
|
427
428
|
}
|
|
@@ -450,8 +451,9 @@ PyObject *BUILTIN_HASH(PyThreadState *tstate, PyObject *value) {
|
|
|
450
451
|
}
|
|
451
452
|
|
|
452
453
|
#if PYTHON_VERSION < 0x300
|
|
453
|
-
return
|
|
454
|
+
return Nuitka_PyInt_FromLong(hash);
|
|
454
455
|
#else
|
|
456
|
+
// TODO: Have a dedicated helper of ours for this as well.
|
|
455
457
|
return PyLong_FromSsize_t(hash);
|
|
456
458
|
#endif
|
|
457
459
|
}
|
|
@@ -459,7 +461,7 @@ PyObject *BUILTIN_HASH(PyThreadState *tstate, PyObject *value) {
|
|
|
459
461
|
#if PYTHON_VERSION < 0x300
|
|
460
462
|
if (likely(type->tp_compare == NULL && TP_RICHCOMPARE(type) == NULL)) {
|
|
461
463
|
Py_hash_t hash = Nuitka_HashFromPointer(value);
|
|
462
|
-
return
|
|
464
|
+
return Nuitka_PyInt_FromLong(hash);
|
|
463
465
|
}
|
|
464
466
|
#endif
|
|
465
467
|
|
|
@@ -553,7 +555,7 @@ PyObject *BUILTIN_BYTEARRAY3(PyThreadState *tstate, PyObject *string, PyObject *
|
|
|
553
555
|
* This comes in two flavors, with one or two arguments. The second one
|
|
554
556
|
* creates a "calliterobject" that is private to CPython. We define it here
|
|
555
557
|
* for ourselves. The one argument version is in headers for in-lining of
|
|
556
|
-
* the code.
|
|
558
|
+
* the code. spell-checker: ignore calliterobject
|
|
557
559
|
*
|
|
558
560
|
**/
|
|
559
561
|
|
|
@@ -720,13 +722,18 @@ PyObject *BUILTIN_GETATTR(PyThreadState *tstate, PyObject *object, PyObject *att
|
|
|
720
722
|
PyObject *result = PyObject_GetAttr(object, attribute);
|
|
721
723
|
|
|
722
724
|
if (result == NULL) {
|
|
723
|
-
if (default_value != NULL
|
|
724
|
-
|
|
725
|
-
|
|
725
|
+
if (default_value != NULL) {
|
|
726
|
+
if (HAS_ERROR_OCCURRED(tstate)) {
|
|
727
|
+
if (EXCEPTION_MATCH_BOOL_SINGLE(tstate, GET_ERROR_OCCURRED(tstate), PyExc_AttributeError)) {
|
|
728
|
+
CLEAR_ERROR_OCCURRED(tstate);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
726
731
|
|
|
727
732
|
Py_INCREF(default_value);
|
|
728
733
|
return default_value;
|
|
729
734
|
} else {
|
|
735
|
+
assert(HAS_ERROR_OCCURRED(tstate));
|
|
736
|
+
|
|
730
737
|
return NULL;
|
|
731
738
|
}
|
|
732
739
|
} else {
|
|
@@ -750,7 +757,7 @@ PyObject *BUILTIN_SETATTR(PyObject *object, PyObject *attribute, PyObject *value
|
|
|
750
757
|
}
|
|
751
758
|
|
|
752
759
|
PyObject *BUILTIN_INT2(PyThreadState *tstate, PyObject *value, PyObject *base) {
|
|
753
|
-
#if PYTHON_VERSION <
|
|
760
|
+
#if PYTHON_VERSION < 0x300
|
|
754
761
|
long base_int = PyInt_AsLong(base);
|
|
755
762
|
#else
|
|
756
763
|
Py_ssize_t base_int = PyNumber_AsSsize_t(base, NULL);
|
|
@@ -759,7 +766,9 @@ PyObject *BUILTIN_INT2(PyThreadState *tstate, PyObject *value, PyObject *base) {
|
|
|
759
766
|
if (unlikely(base_int == -1)) {
|
|
760
767
|
PyObject *error = GET_ERROR_OCCURRED(tstate);
|
|
761
768
|
|
|
762
|
-
if (likely(error)) {
|
|
769
|
+
if (likely(error != NULL)) {
|
|
770
|
+
assert(HAS_ERROR_OCCURRED(tstate));
|
|
771
|
+
|
|
763
772
|
#if PYTHON_VERSION >= 0x300
|
|
764
773
|
if (EXCEPTION_MATCH_BOOL_SINGLE(tstate, error, PyExc_OverflowError)) {
|
|
765
774
|
PyErr_Format(PyExc_ValueError,
|
|
@@ -148,8 +148,8 @@ static PyObject *callPythonFunctionNoArgs(PyObject *func) {
|
|
|
148
148
|
|
|
149
149
|
#endif
|
|
150
150
|
|
|
151
|
-
PyObject *
|
|
152
|
-
|
|
151
|
+
PyObject *CALL_METHOD_WITH_POS_ARGS(PyThreadState *tstate, PyObject *source, PyObject *attr_name,
|
|
152
|
+
PyObject *positional_args) {
|
|
153
153
|
CHECK_OBJECT(source);
|
|
154
154
|
CHECK_OBJECT(attr_name);
|
|
155
155
|
CHECK_OBJECT(positional_args);
|
|
@@ -170,7 +170,7 @@ PyObject *CALL_METHOD_WITH_POSARGS(PyThreadState *tstate, PyObject *source, PyOb
|
|
|
170
170
|
// Note: The "called_object" was found without taking a reference,
|
|
171
171
|
// so we need not release it in this branch.
|
|
172
172
|
if (called_object != NULL) {
|
|
173
|
-
return
|
|
173
|
+
return CALL_FUNCTION_WITH_POS_ARGS(tstate, called_object, positional_args);
|
|
174
174
|
}
|
|
175
175
|
// Then check the class dictionaries.
|
|
176
176
|
called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
|
|
@@ -191,11 +191,11 @@ PyObject *CALL_METHOD_WITH_POSARGS(PyThreadState *tstate, PyObject *source, PyOb
|
|
|
191
191
|
return NULL;
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
PyObject *result =
|
|
194
|
+
PyObject *result = CALL_FUNCTION_WITH_POS_ARGS(tstate, method, positional_args);
|
|
195
195
|
Py_DECREF(method);
|
|
196
196
|
return result;
|
|
197
197
|
} else {
|
|
198
|
-
return
|
|
198
|
+
return CALL_FUNCTION_WITH_POS_ARGS(tstate, called_object, positional_args);
|
|
199
199
|
}
|
|
200
200
|
} else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
|
|
201
201
|
PyErr_Format(PyExc_AttributeError, "%s instance has no attribute '%s'",
|
|
@@ -214,7 +214,7 @@ PyObject *CALL_METHOD_WITH_POSARGS(PyThreadState *tstate, PyObject *source, PyOb
|
|
|
214
214
|
return NULL;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
PyObject *result =
|
|
217
|
+
PyObject *result = CALL_FUNCTION_WITH_POS_ARGS(tstate, called_object, positional_args);
|
|
218
218
|
Py_DECREF(called_object);
|
|
219
219
|
return result;
|
|
220
220
|
}
|
|
@@ -240,7 +240,7 @@ PyObject *CALL_METHOD_WITH_POSARGS(PyThreadState *tstate, PyObject *source, PyOb
|
|
|
240
240
|
return NULL;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
PyObject *result =
|
|
243
|
+
PyObject *result = CALL_FUNCTION_WITH_POS_ARGS(tstate, called_object, positional_args);
|
|
244
244
|
Py_DECREF(called_object);
|
|
245
245
|
return result;
|
|
246
246
|
}
|