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

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, 2 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_gdb.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
642 /* Constant kept for backward compatibility */
638 #define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0 643 #define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0
639 #endif
640 644
641 /* Objects support type attribute cache */ 645 /* Objects support type attribute cache */
642 #define Py_TPFLAGS_HAVE_VERSION_TAG (1UL << 18) 646 #define Py_TPFLAGS_HAVE_VERSION_TAG (1UL << 18)
643 #define Py_TPFLAGS_VALID_VERSION_TAG (1UL << 19) 647 #define Py_TPFLAGS_VALID_VERSION_TAG (1UL << 19)
644 648
645 /* Type is abstract and cannot be instantiated */ 649 /* Type is abstract and cannot be instantiated */
646 #define Py_TPFLAGS_IS_ABSTRACT (1UL << 20) 650 #define Py_TPFLAGS_IS_ABSTRACT (1UL << 20)
647 651
648 /* These flags are used to determine if a type is a subclass. */ 652 /* These flags are used to determine if a type is a subclass. */
649 #define Py_TPFLAGS_LONG_SUBCLASS (1UL << 24) 653 #define Py_TPFLAGS_LONG_SUBCLASS (1UL << 24)
650 #define Py_TPFLAGS_LIST_SUBCLASS (1UL << 25) 654 #define Py_TPFLAGS_LIST_SUBCLASS (1UL << 25)
651 #define Py_TPFLAGS_TUPLE_SUBCLASS (1UL << 26) 655 #define Py_TPFLAGS_TUPLE_SUBCLASS (1UL << 26)
652 #define Py_TPFLAGS_BYTES_SUBCLASS (1UL << 27) 656 #define Py_TPFLAGS_BYTES_SUBCLASS (1UL << 27)
653 #define Py_TPFLAGS_UNICODE_SUBCLASS (1UL << 28) 657 #define Py_TPFLAGS_UNICODE_SUBCLASS (1UL << 28)
654 #define Py_TPFLAGS_DICT_SUBCLASS (1UL << 29) 658 #define Py_TPFLAGS_DICT_SUBCLASS (1UL << 29)
655 #define Py_TPFLAGS_BASE_EXC_SUBCLASS (1UL << 30) 659 #define Py_TPFLAGS_BASE_EXC_SUBCLASS (1UL << 30)
656 #define Py_TPFLAGS_TYPE_SUBCLASS (1UL << 31) 660 #define Py_TPFLAGS_TYPE_SUBCLASS (1UL << 31)
657
658 #define Py_TPFLAGS_DEFAULT ( \
659 Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \
660 Py_TPFLAGS_HAVE_VERSION_TAG | \
661 0)
662 661
663 /* NOTE: The following flags reuse lower bits (removed as part of the 662 /* NOTE: The following flags reuse lower bits (removed as part of the
664 * Python 3.0 transition). */ 663 * Python 3.0 transition). */
665 664
666 /* Type structure has tp_finalize member (3.4) */ 665 /* Type structure has tp_finalize member (3.4), it can be NULL */
667 #define Py_TPFLAGS_HAVE_FINALIZE (1UL << 0) 666 #define Py_TPFLAGS_HAVE_FINALIZE (1UL << 0)
667
668 /* Type structure has tp_fastcall member (3.7), it can be NULL */
669 #define Py_TPFLAGS_HAVE_FASTCALL (1UL << 15)
670
671 #define Py_TPFLAGS_DEFAULT ( \
672 Py_TPFLAGS_HAVE_VERSION_TAG | \
673 Py_TPFLAGS_HAVE_FINALIZE | \
674 Py_TPFLAGS_HAVE_FASTCALL | \
675 0)
668 676
669 #ifdef Py_LIMITED_API 677 #ifdef Py_LIMITED_API
670 #define PyType_HasFeature(t,f) ((PyType_GetFlags(t) & (f)) != 0) 678 #define PyType_HasFeature(t,f) ((PyType_GetFlags(t) & (f)) != 0)
671 #else 679 #else
672 #define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0) 680 #define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0)
673 #endif 681 #endif
674 #define PyType_FastSubclass(t,f) PyType_HasFeature(t,f) 682 #define PyType_FastSubclass(t,f) PyType_HasFeature(t,f)
675 683
676 684
677 /* 685 /*
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 _PyDebugAllocatorStats(FILE *out, const char *block_name, int num_blocks, 1076 _PyDebugAllocatorStats(FILE *out, const char *block_name, int num_blocks,
1069 size_t sizeof_block); 1077 size_t sizeof_block);
1070 PyAPI_FUNC(void) 1078 PyAPI_FUNC(void)
1071 _PyObject_DebugTypeStats(FILE *out); 1079 _PyObject_DebugTypeStats(FILE *out);
1072 #endif /* ifndef Py_LIMITED_API */ 1080 #endif /* ifndef Py_LIMITED_API */
1073 1081
1074 #ifdef __cplusplus 1082 #ifdef __cplusplus
1075 } 1083 }
1076 #endif 1084 #endif
1077 #endif /* !Py_OBJECT_H */ 1085 #endif /* !Py_OBJECT_H */
OLDNEW
« no previous file with comments | « Include/methodobject.h ('k') | Lib/test/test_gdb.py » ('j') | no next file with comments »

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