mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Fix Pyston speedups (#281)
We remove (i.e. hide behind a debug ifdef) the recursion checking methods, and the memory hooks and memory allocator methods. ASAN mode has no PYMALLOC, so we need a macro. Fix build break with des.c stack allocation.
This commit is contained in:
parent
2fe8571010
commit
57f0eed382
42 changed files with 260 additions and 63 deletions
4
third_party/python/Python/finalize.c
vendored
4
third_party/python/Python/finalize.c
vendored
|
@ -121,7 +121,7 @@ Py_FinalizeEx(void)
|
|||
_PyGC_CollectIfEnabled();
|
||||
#endif
|
||||
|
||||
#ifdef MODE_DBG
|
||||
#if IsModeDbg()
|
||||
/* Disable tracemalloc after all Python objects have been destroyed,
|
||||
so it is possible to use tracemalloc in objects destructor. */
|
||||
_PyTraceMalloc_Fini();
|
||||
|
@ -219,11 +219,13 @@ Py_FinalizeEx(void)
|
|||
_Py_PrintReferenceAddresses(stderr);
|
||||
#endif /* Py_TRACE_REFS */
|
||||
#ifdef WITH_PYMALLOC
|
||||
#if IsModeDbg()
|
||||
if (_PyMem_PymallocEnabled()) {
|
||||
char *opt = Py_GETENV("PYTHONMALLOCSTATS");
|
||||
if (opt != NULL && *opt != '\0')
|
||||
_PyObject_DebugMallocStats(stderr);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
_Py_CallLlExitFuncs();
|
||||
|
|
2
third_party/python/Python/pylifecycle.c
vendored
2
third_party/python/Python/pylifecycle.c
vendored
|
@ -274,7 +274,7 @@ _Py_InitializeEx_Private(int install_sigs, int install_importlib)
|
|||
if (install_sigs)
|
||||
_Py_InitSigs(); /* Signal handling stuff, including initintr() */
|
||||
|
||||
#ifdef USE_TRACEMALLOC
|
||||
#if IsModeDbg()
|
||||
if (_PyTraceMalloc_Init() < 0)
|
||||
Py_FatalError("Py_Initialize: can't initialize tracemalloc");
|
||||
#endif
|
||||
|
|
8
third_party/python/Python/sysmodule.c
vendored
8
third_party/python/Python/sysmodule.c
vendored
|
@ -91,7 +91,9 @@ PYTHON_PROVIDE("sys.float_info");
|
|||
PYTHON_PROVIDE("sys.float_repr_style");
|
||||
PYTHON_PROVIDE("sys.get_asyncgen_hooks");
|
||||
PYTHON_PROVIDE("sys.get_coroutine_wrapper");
|
||||
#if IsModeDbg()
|
||||
PYTHON_PROVIDE("sys.getallocatedblocks");
|
||||
#endif
|
||||
PYTHON_PROVIDE("sys.getcheckinterval");
|
||||
PYTHON_PROVIDE("sys.getdefaultencoding");
|
||||
PYTHON_PROVIDE("sys.getdlopenflags");
|
||||
|
@ -1262,6 +1264,7 @@ one higher than you might expect, because it includes the (temporary)\n\
|
|||
reference as an argument to getrefcount()."
|
||||
);
|
||||
|
||||
#if IsModeDbg()
|
||||
static PyObject *
|
||||
sys_getallocatedblocks(PyObject *self)
|
||||
{
|
||||
|
@ -1274,6 +1277,7 @@ PyDoc_STRVAR(getallocatedblocks_doc,
|
|||
Return the number of memory blocks currently allocated, regardless of their\n\
|
||||
size."
|
||||
);
|
||||
#endif
|
||||
|
||||
#ifdef COUNT_ALLOCS
|
||||
static PyObject *
|
||||
|
@ -1382,10 +1386,12 @@ static PyObject *
|
|||
sys_debugmallocstats(PyObject *self, PyObject *args)
|
||||
{
|
||||
#ifdef WITH_PYMALLOC
|
||||
#if IsModeDbg()
|
||||
if (_PyMem_PymallocEnabled()) {
|
||||
_PyObject_DebugMallocStats(stderr);
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
_PyObject_DebugTypeStats(stderr);
|
||||
|
||||
|
@ -1455,8 +1461,10 @@ static PyMethodDef sys_methods[] = {
|
|||
{"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS,
|
||||
getdlopenflags_doc},
|
||||
#endif
|
||||
#if IsModeDbg()
|
||||
{"getallocatedblocks", (PyCFunction)sys_getallocatedblocks, METH_NOARGS,
|
||||
getallocatedblocks_doc},
|
||||
#endif
|
||||
#ifdef COUNT_ALLOCS
|
||||
{"getcounts", (PyCFunction)sys_getcounts, METH_NOARGS},
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue