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

Delta Between Two Patch Sets: Objects/abstract.c

Issue 29259: Add tp_fastcall to PyTypeObject: support FASTCALL calling convention for all callable objects
Left Patch Set: Created 3 years ago
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
(Both sides are equal)
1 /* Abstract Object Interface (many thanks to Jim Fulton) */ 1 /* Abstract Object Interface (many thanks to Jim Fulton) */
2 2
3 #include "Python.h" 3 #include "Python.h"
4 #include <ctype.h> 4 #include <ctype.h>
5 #include "structmember.h" /* we need the offsetof() macro from there */ 5 #include "structmember.h" /* we need the offsetof() macro from there */
6 #include "longintrepr.h" 6 #include "longintrepr.h"
7 7
8 8
9 9
10 /* Shorthands to return certain errors */ 10 /* Shorthands to return certain errors */
(...skipping 2269 matching lines...) Expand 10 before | Expand all | Expand 10 after
2280 } 2280 }
2281 2281
2282 for (i=0; i < nargs; i++) { 2282 for (i=0; i < nargs; i++) {
2283 PyObject *item = stack[i]; 2283 PyObject *item = stack[i];
2284 Py_INCREF(item); 2284 Py_INCREF(item);
2285 PyTuple_SET_ITEM(args, i, item); 2285 PyTuple_SET_ITEM(args, i, item);
2286 } 2286 }
2287 return args; 2287 return args;
2288 } 2288 }
2289 2289
2290 int _Py_NO_INLINE 2290 int _Py_NO_INLINE
haypo 2017/01/26 03:35:21 Not sure if _Py_NO_INLINE is needed here.
2291 _PyStack_AsTupleAndDict(PyObject **stack, Py_ssize_t nargs, PyObject *kwnames, 2291 _PyStack_AsTupleAndDict(PyObject **stack, Py_ssize_t nargs, PyObject *kwnames,
2292 PyObject **p_args, PyObject **p_kwargs) 2292 PyObject **p_args, PyObject **p_kwargs)
2293 { 2293 {
2294 PyObject *args, *kwargs; 2294 PyObject *args, *kwargs;
2295 2295
2296 args = _PyStack_AsTuple(stack, nargs); 2296 args = _PyStack_AsTuple(stack, nargs);
2297 if (args == NULL) { 2297 if (args == NULL) {
2298 return -1; 2298 return -1;
2299 } 2299 }
2300 2300
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
2600 assert(!PyErr_Occurred()); 2600 assert(!PyErr_Occurred());
2601 2601
2602 assert(nargs >= 0); 2602 assert(nargs >= 0);
2603 assert(kwnames == NULL || PyTuple_CheckExact(kwnames)); 2603 assert(kwnames == NULL || PyTuple_CheckExact(kwnames));
2604 2604
2605 /* kwnames must only contains str strings, no subclass, and all keys must 2605 /* kwnames must only contains str strings, no subclass, and all keys must
2606 be unique: these checks are implemented in Python/ceval.c and 2606 be unique: these checks are implemented in Python/ceval.c and
2607 _PyArg_ParseStackAndKeywords(). */ 2607 _PyArg_ParseStackAndKeywords(). */
2608 2608
2609 if (PyFunction_Check(callable)) { 2609 if (PyFunction_Check(callable)) {
2610 /* FIXME: should we use Py_EnterRecursiveCall() here? */ 2610 /* FIXME: should we use Py_EnterRecursiveCall() here? */
haypo 2017/01/26 03:35:21 The FIXME can be removed, the issue is now tracked
2611 return _PyFunction_FastCallKeywords(callable, stack, nargs, kwnames); 2611 return _PyFunction_FastCallKeywords(callable, stack, nargs, kwnames);
2612 } 2612 }
2613 if (PyCFunction_Check(callable)) { 2613 if (PyCFunction_Check(callable)) {
2614 return _PyCFunction_FastCallKeywords(callable, stack, nargs, kwnames); 2614 return _PyCFunction_FastCallKeywords(callable, stack, nargs, kwnames);
2615 } 2615 }
2616 else if (PyType_HasFeature(Py_TYPE(callable), Py_TPFLAGS_HAVE_FASTCALL) 2616 else if (PyType_HasFeature(Py_TYPE(callable), Py_TPFLAGS_HAVE_FASTCALL)
2617 && Py_TYPE(callable)->tp_fastcall) { 2617 && Py_TYPE(callable)->tp_fastcall) {
2618 fastternaryfunc fastcall = Py_TYPE(callable)->tp_fastcall; 2618 fastternaryfunc fastcall = Py_TYPE(callable)->tp_fastcall;
2619 PyObject *result; 2619 PyObject *result;
2620 2620
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
3380 /* Free's a NULL terminated char** array of C strings. */ 3380 /* Free's a NULL terminated char** array of C strings. */
3381 void 3381 void
3382 _Py_FreeCharPArray(char *const array[]) 3382 _Py_FreeCharPArray(char *const array[])
3383 { 3383 {
3384 Py_ssize_t i; 3384 Py_ssize_t i;
3385 for (i = 0; array[i] != NULL; ++i) { 3385 for (i = 0; array[i] != NULL; ++i) {
3386 PyMem_Free(array[i]); 3386 PyMem_Free(array[i]);
3387 } 3387 }
3388 PyMem_Free((void*)array); 3388 PyMem_Free((void*)array);
3389 } 3389 }
LEFTRIGHT

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