Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(15)

Side by Side Diff: Include/abstract.h

Issue 29259: Add tp_fastcall to PyTypeObject: support FASTCALL calling convention for all callable objects
Patch Set: Created 3 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Include/descrobject.h » ('j') | Objects/abstract.c » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Abstract Object Interface (many thanks to Jim Fulton) */ 1 /* Abstract Object Interface (many thanks to Jim Fulton) */
2 2
3 #ifndef Py_ABSTRACTOBJECT_H 3 #ifndef Py_ABSTRACTOBJECT_H
4 #define Py_ABSTRACTOBJECT_H 4 #define Py_ABSTRACTOBJECT_H
5 #ifdef __cplusplus 5 #ifdef __cplusplus
6 extern "C" { 6 extern "C" {
7 #endif 7 #endif
8 8
9 /* === Object Protocol ================================================== */ 9 /* === Object Protocol ================================================== */
10 10
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 arguments is reponsible to check if all keys are strings, for example using 173 arguments is reponsible to check if all keys are strings, for example using
174 PyArg_ParseTupleAndKeywords() or PyArg_ValidateKeywordArguments(). 174 PyArg_ParseTupleAndKeywords() or PyArg_ValidateKeywordArguments().
175 175
176 Duplicate keys are merged using the last value. If duplicate keys must raise 176 Duplicate keys are merged using the last value. If duplicate keys must raise
177 an exception, the caller is responsible to implement an explicit keys on 177 an exception, the caller is responsible to implement an explicit keys on
178 kwnames. */ 178 kwnames. */
179 PyAPI_FUNC(PyObject *) _PyStack_AsDict( 179 PyAPI_FUNC(PyObject *) _PyStack_AsDict(
180 PyObject **values, 180 PyObject **values,
181 PyObject *kwnames); 181 PyObject *kwnames);
182 182
183 /* Convert (args, nargs, kwargs: dict) into a (stack, nargs, kwnames: tuple). 183 /* Convert FASTCALL (stack, nargs, kwnames) arguments
184 to (args: tuple, kwargs: dict) format.
184 185
185 Return 0 on success, raise an exception and return -1 on error. 186 Return 0 on success. Raise an exception and return -1 on error.
186 187
187 Write the new stack into *p_stack. If *p_stack is differen than args, it 188 The function combines _PyStack_AsTuple() and _PyStack_AsDict(). */
188 must be released by PyMem_Free(). 189 PyAPI_FUNC(int) _PyStack_AsTupleAndDict(
189 190 PyObject **stack,
190 The stack uses borrowed references.
191
192 The type of keyword keys is not checked, these checks should be done
193 later (ex: _PyArg_ParseStackAndKeywords). */
194 PyAPI_FUNC(int) _PyStack_UnpackDict(
195 PyObject **args,
196 Py_ssize_t nargs, 191 Py_ssize_t nargs,
197 PyObject *kwargs, 192 PyObject *kwnames,
198 PyObject ***p_stack, 193 PyObject **p_args,
199 PyObject **p_kwnames); 194 PyObject **p_kwargs);
200 195
201 /* Suggested size (number of positional arguments) for arrays of PyObject* 196 /* Suggested size (number of positional arguments) for arrays of PyObject*
202 allocated on a C stack to avoid allocating memory on the heap memory. Such 197 allocated on a C stack to avoid allocating memory on the heap memory. Such
203 array is used to pass positional arguments to call functions of the 198 array is used to pass positional arguments to call functions of the
204 _PyObject_FastCall() family. 199 _PyObject_FastCall() family.
205 200
206 The size is chosen to not abuse the C stack and so limit the risk of stack 201 The size is chosen to not abuse the C stack and so limit the risk of stack
207 overflow. The size is also chosen to allow using the small stack for most 202 overflow. The size is also chosen to allow using the small stack for most
208 function calls of the Python standard library. On 64-bit CPU, it allocates 203 function calls of the Python standard library. On 64-bit CPU, it allocates
209 40 bytes on the stack. */ 204 40 bytes on the stack. */
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 _PyObject_FastCallDict((func), (args), (nargs), NULL) 244 _PyObject_FastCallDict((func), (args), (nargs), NULL)
250 245
251 #define _PyObject_CallNoArg(func) \ 246 #define _PyObject_CallNoArg(func) \
252 _PyObject_FastCallDict((func), NULL, 0, NULL) 247 _PyObject_FastCallDict((func), NULL, 0, NULL)
253 248
254 PyAPI_FUNC(PyObject *) _PyObject_Call_Prepend( 249 PyAPI_FUNC(PyObject *) _PyObject_Call_Prepend(
255 PyObject *callable, 250 PyObject *callable,
256 PyObject *obj, 251 PyObject *obj,
257 PyObject *args, 252 PyObject *args,
258 PyObject *kwargs); 253 PyObject *kwargs);
254
255 PyAPI_FUNC(PyObject *) _PyObject_FastCall_Prepend(PyObject *func,
256 PyObject *obj,
257 PyObject **args,
258 Py_ssize_t nargs,
259 PyObject *kwnames);
260
261 PyAPI_FUNC(int) _PyStack_UnpackDict(PyObject **args, Py_ssize_t nargs,
262 PyObject *kwargs,
263 PyObject ***p_stack, PyObject **p_kwnames);
259 264
260 PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *callable, 265 PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *callable,
261 PyObject *result, 266 PyObject *result,
262 const char *where); 267 const char *where);
263 #endif /* Py_LIMITED_API */ 268 #endif /* Py_LIMITED_API */
264 269
265 270
271 #ifdef Py_BUILD_CORE
272 /* Low-level function to call a C function using FASTCALL calling convention.
273 Don't check the result: the caller must check _Py_CheckFunctionResult(). */
274 PyAPI_FUNC(PyObject *) _Py_RawFastCallDict(
275 PyObject *self,
276 fastternaryfunc fastcall,
277 PyObject **args,
278 Py_ssize_t nargs,
279 PyObject *kwargs);
280 #endif
281
282
266 /* Call a callable Python object 'callable', with arguments given by the 283 /* Call a callable Python object 'callable', with arguments given by the
267 tuple 'args'. If no arguments are needed, then 'args' can be *NULL*. 284 tuple 'args'. If no arguments are needed, then 'args' can be *NULL*.
268 285
269 Returns the result of the call on success, or *NULL* on failure. 286 Returns the result of the call on success, or *NULL* on failure.
270 287
271 This is the equivalent of the Python expression: 288 This is the equivalent of the Python expression:
272 callable(*args). */ 289 callable(*args). */
273 PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable, 290 PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable,
274 PyObject *args); 291 PyObject *args);
275 292
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 const Py_ssize_t *shape); 1104 const Py_ssize_t *shape);
1088 PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index, 1105 PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index,
1089 const Py_ssize_t *shape); 1106 const Py_ssize_t *shape);
1090 #endif /* !Py_LIMITED_API */ 1107 #endif /* !Py_LIMITED_API */
1091 1108
1092 1109
1093 #ifdef __cplusplus 1110 #ifdef __cplusplus
1094 } 1111 }
1095 #endif 1112 #endif
1096 #endif /* Py_ABSTRACTOBJECT_H */ 1113 #endif /* Py_ABSTRACTOBJECT_H */
OLDNEW
« no previous file with comments | « no previous file | Include/descrobject.h » ('j') | Objects/abstract.c » ('J')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+