mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Backport METH_FASTCALL from Python 3.7 (#328)
This commit is contained in:
parent
70c97f598b
commit
cf73bbd678
102 changed files with 2896 additions and 3301 deletions
2
third_party/python/Include/abstract.h
vendored
2
third_party/python/Include/abstract.h
vendored
|
@ -44,6 +44,8 @@ PyObject *_PyObject_Call_Prepend(PyObject *func, PyObject *obj, PyObject *args,
|
|||
|
||||
#define _PY_FASTCALL_SMALL_STACK 5
|
||||
|
||||
int _PyObject_HasFastCall(PyObject *callable);
|
||||
|
||||
PyObject *_PyObject_FastCall_Prepend(
|
||||
PyObject *callable,
|
||||
PyObject *obj,
|
||||
|
|
2
third_party/python/Include/descrobject.h
vendored
2
third_party/python/Include/descrobject.h
vendored
|
@ -91,6 +91,8 @@ PyObject * PyDescr_NewMember(PyTypeObject *,
|
|||
PyObject * PyDescr_NewGetSet(PyTypeObject *,
|
||||
struct PyGetSetDef *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyObject * _PyMethodDescr_FastCallKeywords(
|
||||
PyObject *descrobj, PyObject *const *stack, Py_ssize_t nargs, PyObject *kwnames);
|
||||
PyObject * PyDescr_NewWrapper(PyTypeObject *,
|
||||
struct wrapperbase *, void *);
|
||||
#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL)
|
||||
|
|
10
third_party/python/Include/eval.h
vendored
10
third_party/python/Include/eval.h
vendored
|
@ -15,6 +15,16 @@ PyObject * PyEval_EvalCodeEx(PyObject *co,
|
|||
PyObject *kwdefs, PyObject *closure);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyObject * _PyEval_EvalCodeWithName(
|
||||
PyObject *co,
|
||||
PyObject *globals, PyObject *locals,
|
||||
PyObject **args, Py_ssize_t argcount,
|
||||
PyObject **kwnames, PyObject **kwargs,
|
||||
Py_ssize_t kwcount, int kwstep,
|
||||
PyObject **defs, Py_ssize_t defcount,
|
||||
PyObject *kwdefs, PyObject *closure,
|
||||
PyObject *name, PyObject *qualname);
|
||||
|
||||
PyObject * _PyEval_CallTracing(PyObject *func, PyObject *args);
|
||||
#endif
|
||||
|
||||
|
|
3
third_party/python/Include/frameobject.h
vendored
3
third_party/python/Include/frameobject.h
vendored
|
@ -61,6 +61,9 @@ extern PyTypeObject PyFrame_Type;
|
|||
PyFrameObject * PyFrame_New(PyThreadState *, PyCodeObject *,
|
||||
PyObject *, PyObject *);
|
||||
|
||||
/* only internal use */
|
||||
PyFrameObject* _PyFrame_New_NoTrack(PyThreadState *, PyCodeObject *,
|
||||
PyObject *, PyObject *);
|
||||
|
||||
/* The rest of the interface is specific for frame objects */
|
||||
|
||||
|
|
14
third_party/python/Include/methodobject.h
vendored
14
third_party/python/Include/methodobject.h
vendored
|
@ -14,10 +14,12 @@ extern PyTypeObject PyCFunction_Type;
|
|||
#define PyCFunction_Check(op) (Py_TYPE(op) == &PyCFunction_Type)
|
||||
|
||||
typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
|
||||
typedef PyObject *(*_PyCFunctionFast) (PyObject *self, PyObject **args,
|
||||
Py_ssize_t nargs, PyObject *kwnames);
|
||||
typedef PyObject *(*_PyCFunctionFast) (PyObject *, PyObject **, Py_ssize_t);
|
||||
typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *,
|
||||
PyObject *);
|
||||
typedef PyObject *(*_PyCFunctionFastWithKeywords) (PyObject *,
|
||||
PyObject **, Py_ssize_t,
|
||||
PyObject *);
|
||||
typedef PyObject *(*PyNoArgsFunction)(PyObject *);
|
||||
|
||||
PyCFunction PyCFunction_GetFunction(PyObject *);
|
||||
|
@ -93,12 +95,20 @@ typedef struct {
|
|||
PyObject *m_module; /* The __module__ attribute, can be anything */
|
||||
PyObject *m_weakreflist; /* List of weak references */
|
||||
} PyCFunctionObject;
|
||||
|
||||
PyObject * _PyMethodDef_RawFastCallDict(
|
||||
PyMethodDef *method,
|
||||
PyObject *self,
|
||||
PyObject **args,
|
||||
Py_ssize_t nargs,
|
||||
PyObject *kwargs);
|
||||
|
||||
PyObject * _PyMethodDef_RawFastCallKeywords(
|
||||
PyMethodDef *method,
|
||||
PyObject *self,
|
||||
PyObject **args,
|
||||
Py_ssize_t nargs,
|
||||
PyObject *kwnames);
|
||||
#endif
|
||||
|
||||
int PyCFunction_ClearFreeList(void);
|
||||
|
|
2
third_party/python/Include/opcode.h
generated
vendored
2
third_party/python/Include/opcode.h
generated
vendored
|
@ -125,6 +125,8 @@ COSMOPOLITAN_C_START_
|
|||
#define BUILD_CONST_KEY_MAP 156
|
||||
#define BUILD_STRING 157
|
||||
#define BUILD_TUPLE_UNPACK_WITH_CALL 158
|
||||
#define LOAD_METHOD 160
|
||||
#define CALL_METHOD 161
|
||||
|
||||
/* EXCEPT_HANDLER is a special, implicit block type which is created when
|
||||
entering an except handler. It is not an opcode but we define it here
|
||||
|
|
22
third_party/python/Include/pyport.h
vendored
22
third_party/python/Include/pyport.h
vendored
|
@ -235,6 +235,28 @@ typedef int Py_ssize_clean_t;
|
|||
#define Py_DEPRECATED(VERSION_UNUSED)
|
||||
#endif
|
||||
|
||||
/* _Py_HOT_FUNCTION
|
||||
* The hot attribute on a function is used to inform the compiler that the
|
||||
* function is a hot spot of the compiled program. The function is optimized
|
||||
* more aggressively and on many target it is placed into special subsection of
|
||||
* the text section so all hot functions appears close together improving
|
||||
* locality.
|
||||
*
|
||||
* Usage:
|
||||
* int _Py_HOT_FUNCTION x(void) { return 3; }
|
||||
*
|
||||
* Issue #28618: This attribute must not be abused, otherwise it can have a
|
||||
* negative effect on performance. Only the functions were Python spend most of
|
||||
* its time must use it. Use a profiler when running performance benchmark
|
||||
* suite to find these functions.
|
||||
*/
|
||||
#if !IsModeDbg() && defined(__GNUC__) \
|
||||
&& ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))
|
||||
#define _Py_HOT_FUNCTION __attribute__((hot))
|
||||
#else
|
||||
#define _Py_HOT_FUNCTION
|
||||
#endif
|
||||
|
||||
#define RTYPE RTYPE
|
||||
#ifdef __cplusplus
|
||||
#define PyMODINIT_FUNC extern "C" PyObject *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue