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
2
third_party/python/Include/abstract.h
vendored
2
third_party/python/Include/abstract.h
vendored
|
@ -35,7 +35,7 @@ PyObject *_PyObject_FastCallKeywords(PyObject *func, PyObject **args,
|
|||
PyObject *_PyObject_Call_Prepend(PyObject *func, PyObject *obj, PyObject *args,
|
||||
PyObject *kwargs);
|
||||
|
||||
#ifdef USE_CHECKFUNCRESULT
|
||||
#if IsModeDbg()
|
||||
PyObject *_Py_CheckFunctionResult(PyObject *func, PyObject *result,
|
||||
const char *where);
|
||||
#else
|
||||
|
|
5
third_party/python/Include/ceval.h
vendored
5
third_party/python/Include/ceval.h
vendored
|
@ -77,6 +77,7 @@ int Py_MakePendingCalls(void);
|
|||
void Py_SetRecursionLimit(int);
|
||||
int Py_GetRecursionLimit(void);
|
||||
|
||||
#if IsModeDbg()
|
||||
#define Py_EnterRecursiveCall(where) \
|
||||
(_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \
|
||||
_Py_CheckRecursiveCall(where))
|
||||
|
@ -84,6 +85,10 @@ int Py_GetRecursionLimit(void);
|
|||
do{ if(_Py_MakeEndRecCheck(PyThreadState_GET()->recursion_depth)) \
|
||||
PyThreadState_GET()->overflowed = 0; \
|
||||
} while(0)
|
||||
#else
|
||||
#define Py_EnterRecursiveCall(where) (0)
|
||||
#define Py_LeaveRecursiveCall(where) ((void)0)
|
||||
#endif
|
||||
int _Py_CheckRecursiveCall(const char *where);
|
||||
extern int _Py_CheckRecursionLimit;
|
||||
|
||||
|
|
5
third_party/python/Include/objimpl.h
vendored
5
third_party/python/Include/objimpl.h
vendored
|
@ -17,8 +17,10 @@ void * PyObject_Realloc(void *, size_t);
|
|||
void PyObject_Free(void *);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
#if IsModeDbg()
|
||||
/* This function returns the number of allocated memory blocks, regardless of size */
|
||||
Py_ssize_t _Py_GetAllocatedBlocks(void);
|
||||
#endif
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
||||
/* Macros */
|
||||
|
@ -117,6 +119,7 @@ PyVarObject * _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
|
|||
constructor you would start directly with PyObject_Init/InitVar
|
||||
*/
|
||||
|
||||
#if IsModeDbg()
|
||||
#ifndef Py_LIMITED_API
|
||||
typedef struct {
|
||||
/* user context passed as the first argument to the 2 functions */
|
||||
|
@ -135,7 +138,7 @@ void PyObject_GetArenaAllocator(PyObjectArenaAllocator *allocator);
|
|||
/* Set the arena allocator. */
|
||||
void PyObject_SetArenaAllocator(PyObjectArenaAllocator *allocator);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Garbage Collection Support
|
||||
|
|
2
third_party/python/Include/pyerrors.h
vendored
2
third_party/python/Include/pyerrors.h
vendored
|
@ -316,7 +316,7 @@ void PyErr_BadInternalCall(void);
|
|||
void _PyErr_BadInternalCall(const char *filename, int lineno);
|
||||
/* Mask the old API with a call to the new API for code compiled under
|
||||
Python 2.0: */
|
||||
#ifdef USE_BADINTERNALCALL
|
||||
#if IsModeDbg()
|
||||
#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)
|
||||
#else
|
||||
#define PyErr_BadInternalCall()
|
||||
|
|
8
third_party/python/Include/pymem.h
vendored
8
third_party/python/Include/pymem.h
vendored
|
@ -64,13 +64,15 @@ PyObject* _PyTraceMalloc_GetTraceback(
|
|||
_PyTraceMalloc_domain_t domain,
|
||||
uintptr_t ptr);
|
||||
|
||||
#ifdef USE_TRACEMALLOC
|
||||
int _PyMem_IsFreed(void *ptr, size_t size);
|
||||
|
||||
#if !IsModeDbg()
|
||||
#define _PyTraceMalloc_Track(domain, ptr, size) (-2)
|
||||
#define _PyTraceMalloc_Untrack(domain, ptr) (-2)
|
||||
#define _PyTraceMalloc_GetTraceback(domain, ptr) (&_Py_NoneStruct)
|
||||
#define _PyMem_IsFreed(ptr, size) (0)
|
||||
#endif
|
||||
|
||||
int _PyMem_IsFreed(void *ptr, size_t size);
|
||||
#endif /* !defined(Py_LIMITED_API) */
|
||||
|
||||
|
||||
|
@ -172,6 +174,7 @@ char * _PyMem_Strdup(const char *str);
|
|||
#define PyMem_Del PyMem_Free
|
||||
#define PyMem_DEL PyMem_FREE
|
||||
|
||||
#if IsModeDbg()
|
||||
#ifndef Py_LIMITED_API
|
||||
typedef enum {
|
||||
/* PyMem_RawMalloc(), PyMem_RawRealloc() and PyMem_RawFree() */
|
||||
|
@ -237,6 +240,7 @@ void PyMem_SetAllocator(PyMemAllocatorDomain domain,
|
|||
The function does nothing if Python is not compiled is debug mode. */
|
||||
void PyMem_SetupDebugHooks(void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_PYMEM_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue