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

Side by Side Diff: Include/object.h

Issue 29259: Add tp_fastcall to PyTypeObject: support FASTCALL calling convention for all callable objects
Patch Set: Created 3 years, 4 months 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 | « Include/methodobject.h ('k') | Lib/test/test_sys.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #ifndef Py_OBJECT_H 1 #ifndef Py_OBJECT_H
2 #define Py_OBJECT_H 2 #define Py_OBJECT_H
3 #ifdef __cplusplus 3 #ifdef __cplusplus
4 extern "C" { 4 extern "C" {
5 #endif 5 #endif
6 6
7 7
8 /* Object and type object interface */ 8 /* Object and type object interface */
9 9
10 /* 10 /*
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 typedef PyObject *(*reprfunc)(PyObject *); 332 typedef PyObject *(*reprfunc)(PyObject *);
333 typedef Py_hash_t (*hashfunc)(PyObject *); 333 typedef Py_hash_t (*hashfunc)(PyObject *);
334 typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int); 334 typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int);
335 typedef PyObject *(*getiterfunc) (PyObject *); 335 typedef PyObject *(*getiterfunc) (PyObject *);
336 typedef PyObject *(*iternextfunc) (PyObject *); 336 typedef PyObject *(*iternextfunc) (PyObject *);
337 typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *); 337 typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *);
338 typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *); 338 typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *);
339 typedef int (*initproc)(PyObject *, PyObject *, PyObject *); 339 typedef int (*initproc)(PyObject *, PyObject *, PyObject *);
340 typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *); 340 typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *);
341 typedef PyObject *(*allocfunc)(struct _typeobject *, Py_ssize_t); 341 typedef PyObject *(*allocfunc)(struct _typeobject *, Py_ssize_t);
342 typedef PyObject* (*fastternaryfunc) (PyObject *self, PyObject **stack,
343 Py_ssize_t nargs, PyObject *kwnames);
342 344
343 #ifdef Py_LIMITED_API 345 #ifdef Py_LIMITED_API
344 typedef struct _typeobject PyTypeObject; /* opaque */ 346 typedef struct _typeobject PyTypeObject; /* opaque */
345 #else 347 #else
346 typedef struct _typeobject { 348 typedef struct _typeobject {
347 PyObject_VAR_HEAD 349 PyObject_VAR_HEAD
348 const char *tp_name; /* For printing, in format "<module>.<name>" */ 350 const char *tp_name; /* For printing, in format "<module>.<name>" */
349 Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */ 351 Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */
350 352
351 /* Methods to implement standard operations */ 353 /* Methods to implement standard operations */
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 PyObject *tp_mro; /* method resolution order */ 418 PyObject *tp_mro; /* method resolution order */
417 PyObject *tp_cache; 419 PyObject *tp_cache;
418 PyObject *tp_subclasses; 420 PyObject *tp_subclasses;
419 PyObject *tp_weaklist; 421 PyObject *tp_weaklist;
420 destructor tp_del; 422 destructor tp_del;
421 423
422 /* Type attribute cache version tag. Added in version 2.6 */ 424 /* Type attribute cache version tag. Added in version 2.6 */
423 unsigned int tp_version_tag; 425 unsigned int tp_version_tag;
424 426
425 destructor tp_finalize; 427 destructor tp_finalize;
428
429 fastternaryfunc tp_fastcall;
426 430
427 #ifdef COUNT_ALLOCS 431 #ifdef COUNT_ALLOCS
428 /* these must be last and never explicitly initialized */ 432 /* these must be last and never explicitly initialized */
429 Py_ssize_t tp_allocs; 433 Py_ssize_t tp_allocs;
430 Py_ssize_t tp_frees; 434 Py_ssize_t tp_frees;
431 Py_ssize_t tp_maxalloc; 435 Py_ssize_t tp_maxalloc;
432 struct _typeobject *tp_prev; 436 struct _typeobject *tp_prev;
433 struct _typeobject *tp_next; 437 struct _typeobject *tp_next;
434 #endif 438 #endif
435 } PyTypeObject; 439 } PyTypeObject;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 628
625 /* Set if the type is 'ready' -- fully initialized */ 629 /* Set if the type is 'ready' -- fully initialized */
626 #define Py_TPFLAGS_READY (1UL << 12) 630 #define Py_TPFLAGS_READY (1UL << 12)
627 631
628 /* Set while the type is being 'readied', to prevent recursive ready calls */ 632 /* Set while the type is being 'readied', to prevent recursive ready calls */
629 #define Py_TPFLAGS_READYING (1UL << 13) 633 #define Py_TPFLAGS_READYING (1UL << 13)
630 634
631 /* Objects support garbage collection (see objimp.h) */ 635 /* Objects support garbage collection (see objimp.h) */
632 #define Py_TPFLAGS_HAVE_GC (1UL << 14) 636 #define Py_TPFLAGS_HAVE_GC (1UL << 14)
633 637
634 /* These two bits are preserved for Stackless Python, next after this is 17 */ 638 /* Bits 15 and 16 were used by Stackless Python, but are now used for tp_fastcal l */
635 #ifdef STACKLESS 639 #ifdef STACKLESS
636 #define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION (3UL << 15) 640 # error "Stackless is no more supported"
637 #else 641 #endif
638 #define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0 642 #define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0
639 #endif
640 643
641 /* Objects support type attribute cache */ 644 /* Objects support type attribute cache */
642 #define Py_TPFLAGS_HAVE_VERSION_TAG (1UL << 18) 645 #define Py_TPFLAGS_HAVE_VERSION_TAG (1UL << 18)
643 #define Py_TPFLAGS_VALID_VERSION_TAG (1UL << 19) 646 #define Py_TPFLAGS_VALID_VERSION_TAG (1UL << 19)
644 647
645 /* Type is abstract and cannot be instantiated */ 648 /* Type is abstract and cannot be instantiated */
646 #define Py_TPFLAGS_IS_ABSTRACT (1UL << 20) 649 #define Py_TPFLAGS_IS_ABSTRACT (1UL << 20)
647 650
648 /* These flags are used to determine if a type is a subclass. */ 651 /* These flags are used to determine if a type is a subclass. */
649 #define Py_TPFLAGS_LONG_SUBCLASS (1UL << 24) 652 #define Py_TPFLAGS_LONG_SUBCLASS (1UL << 24)
650 #define Py_TPFLAGS_LIST_SUBCLASS (1UL << 25) 653 #define Py_TPFLAGS_LIST_SUBCLASS (1UL << 25)
651 #define Py_TPFLAGS_TUPLE_SUBCLASS (1UL << 26) 654 #define Py_TPFLAGS_TUPLE_SUBCLASS (1UL << 26)
652 #define Py_TPFLAGS_BYTES_SUBCLASS (1UL << 27) 655 #define Py_TPFLAGS_BYTES_SUBCLASS (1UL << 27)
653 #define Py_TPFLAGS_UNICODE_SUBCLASS (1UL << 28) 656 #define Py_TPFLAGS_UNICODE_SUBCLASS (1UL << 28)
654 #define Py_TPFLAGS_DICT_SUBCLASS (1UL << 29) 657 #define Py_TPFLAGS_DICT_SUBCLASS (1UL << 29)
655 #define Py_TPFLAGS_BASE_EXC_SUBCLASS (1UL << 30) 658 #define Py_TPFLAGS_BASE_EXC_SUBCLASS (1UL << 30)
656 #define Py_TPFLAGS_TYPE_SUBCLASS (1UL << 31) 659 #define Py_TPFLAGS_TYPE_SUBCLASS (1UL << 31)
657 660
658 #define Py_TPFLAGS_DEFAULT ( \ 661 #define Py_TPFLAGS_DEFAULT ( \
659 Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \ 662 Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \
660 Py_TPFLAGS_HAVE_VERSION_TAG | \ 663 Py_TPFLAGS_HAVE_VERSION_TAG | \
661 0) 664 0)
662 665
663 /* NOTE: The following flags reuse lower bits (removed as part of the 666 /* NOTE: The following flags reuse lower bits (removed as part of the
664 * Python 3.0 transition). */ 667 * Python 3.0 transition). */
665 668
666 /* Type structure has tp_finalize member (3.4) */ 669 /* Type structure has tp_finalize member (3.4) */
667 #define Py_TPFLAGS_HAVE_FINALIZE (1UL << 0) 670 #define Py_TPFLAGS_HAVE_FINALIZE (1UL << 0)
671
672 /* Type structure has tp_fastcall member (3.7) */
673 #define Py_TPFLAGS_HAVE_FASTCALL (1UL << 15)
668 674
669 #ifdef Py_LIMITED_API 675 #ifdef Py_LIMITED_API
670 #define PyType_HasFeature(t,f) ((PyType_GetFlags(t) & (f)) != 0) 676 #define PyType_HasFeature(t,f) ((PyType_GetFlags(t) & (f)) != 0)
671 #else 677 #else
672 #define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0) 678 #define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0)
673 #endif 679 #endif
674 #define PyType_FastSubclass(t,f) PyType_HasFeature(t,f) 680 #define PyType_FastSubclass(t,f) PyType_HasFeature(t,f)
681
682
683 #ifndef Py_LIMITED_API
684 # define _Py_TYPE_HAS_FASTCALL(type) \
685 (((type)->tp_flags & Py_TPFLAGS_HAVE_FASTCALL) \
686 && ((type)->tp_fastcall != NULL))
687 #endif
675 688
676 689
677 /* 690 /*
678 The macros Py_INCREF(op) and Py_DECREF(op) are used to increment or decrement 691 The macros Py_INCREF(op) and Py_DECREF(op) are used to increment or decrement
679 reference counts. Py_DECREF calls the object's deallocator function when 692 reference counts. Py_DECREF calls the object's deallocator function when
680 the refcount falls to 0; for 693 the refcount falls to 0; for
681 objects that don't contain references to other objects or heap memory 694 objects that don't contain references to other objects or heap memory
682 this can be the standard function free(). Both macros can be used 695 this can be the standard function free(). Both macros can be used
683 wherever a void expression is allowed. The argument must not be a 696 wherever a void expression is allowed. The argument must not be a
684 NULL pointer. If it may be NULL, use Py_XINCREF/Py_XDECREF instead. 697 NULL pointer. If it may be NULL, use Py_XINCREF/Py_XDECREF instead.
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 _PyDebugAllocatorStats(FILE *out, const char *block_name, int num_blocks, 1081 _PyDebugAllocatorStats(FILE *out, const char *block_name, int num_blocks,
1069 size_t sizeof_block); 1082 size_t sizeof_block);
1070 PyAPI_FUNC(void) 1083 PyAPI_FUNC(void)
1071 _PyObject_DebugTypeStats(FILE *out); 1084 _PyObject_DebugTypeStats(FILE *out);
1072 #endif /* ifndef Py_LIMITED_API */ 1085 #endif /* ifndef Py_LIMITED_API */
1073 1086
1074 #ifdef __cplusplus 1087 #ifdef __cplusplus
1075 } 1088 }
1076 #endif 1089 #endif
1077 #endif /* !Py_OBJECT_H */ 1090 #endif /* !Py_OBJECT_H */
OLDNEW
« no previous file with comments | « Include/methodobject.h ('k') | Lib/test/test_sys.py » ('j') | no next file with comments »

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