diff options
author | Victor Stinner <vstinner@python.org> | 2022-02-25 14:41:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-25 14:41:32 (GMT) |
commit | 4a0c7a1aacd08cead7717479620e62359c828e88 (patch) | |
tree | b063780754c9919fd7f468c8d30f027b3c0c765e /Include/internal/pycore_code.h | |
parent | c579243eb62d3182c84004cd72dcf6ef59100643 (diff) | |
download | cpython-4a0c7a1aacd08cead7717479620e62359c828e88.zip cpython-4a0c7a1aacd08cead7717479620e62359c828e88.tar.gz cpython-4a0c7a1aacd08cead7717479620e62359c828e88.tar.bz2 |
bpo-45316: Move private PyCode C API to internal C API (GH-31576)
Rename private functions (no exported), add an underscore prefix:
* PyLineTable_InitAddressRange() => _PyLineTable_InitAddressRange()
* PyLineTable_NextAddressRange() => _PyLineTable_NextAddressRange()
* PyLineTable_PreviousAddressRange() => _PyLineTable_PreviousAddressRange()
Move private functions to the internal C API:
* _PyCode_Addr2EndLine()
* _PyCode_Addr2EndOffset()
* _PyCode_Addr2Offset()
* _PyCode_InitAddressRange()
* _PyCode_InitEndAddressRange(
* _PyLineTable_InitAddressRange()
* _PyLineTable_NextAddressRange()
* _PyLineTable_PreviousAddressRange()
No longer export the following internal functions:
* _PyCode_GetVarnames()
* _PyCode_GetCellvars()
* _PyCode_GetFreevars()
* _Py_GetSpecializationStats()
Add "extern" to pycore_code.h functions to identify them more easiliy
(they are still not exported).
Diffstat (limited to 'Include/internal/pycore_code.h')
-rw-r--r-- | Include/internal/pycore_code.h | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h index 2791495..d83df5e 100644 --- a/Include/internal/pycore_code.h +++ b/Include/internal/pycore_code.h @@ -259,9 +259,35 @@ PyAPI_FUNC(PyCodeObject *) _PyCode_New(struct _PyCodeConstructor *); /* Private API */ /* Getters for internal PyCodeObject data. */ -PyAPI_FUNC(PyObject *) _PyCode_GetVarnames(PyCodeObject *); -PyAPI_FUNC(PyObject *) _PyCode_GetCellvars(PyCodeObject *); -PyAPI_FUNC(PyObject *) _PyCode_GetFreevars(PyCodeObject *); +extern PyObject* _PyCode_GetVarnames(PyCodeObject *); +extern PyObject* _PyCode_GetCellvars(PyCodeObject *); +extern PyObject* _PyCode_GetFreevars(PyCodeObject *); + +/* Return the ending source code line number from a bytecode index. */ +extern int _PyCode_Addr2EndLine(PyCodeObject *, int); + +/* Return the ending source code line number from a bytecode index. */ +extern int _PyCode_Addr2EndLine(PyCodeObject *, int); +/* Return the starting source code column offset from a bytecode index. */ +extern int _PyCode_Addr2Offset(PyCodeObject *, int); +/* Return the ending source code column offset from a bytecode index. */ +extern int _PyCode_Addr2EndOffset(PyCodeObject *, int); + +/** API for initializing the line number tables. */ +extern int _PyCode_InitAddressRange(PyCodeObject* co, PyCodeAddressRange *bounds); +extern int _PyCode_InitEndAddressRange(PyCodeObject* co, PyCodeAddressRange* bounds); + +/** Out of process API for initializing the line number table. */ +extern void _PyLineTable_InitAddressRange( + const char *linetable, + Py_ssize_t length, + int firstlineno, + PyCodeAddressRange *range); + +/** API for traversing the line number table. */ +extern int _PyLineTable_NextAddressRange(PyCodeAddressRange *range); +extern int _PyLineTable_PreviousAddressRange(PyCodeAddressRange *range); + #define ADAPTIVE_CACHE_BACKOFF 64 @@ -272,26 +298,26 @@ cache_backoff(_PyAdaptiveEntry *entry) { /* Specialization functions */ -int _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, SpecializedCacheEntry *cache); -int _Py_Specialize_StoreAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, SpecializedCacheEntry *cache); -int _Py_Specialize_LoadGlobal(PyObject *globals, PyObject *builtins, _Py_CODEUNIT *instr, PyObject *name, SpecializedCacheEntry *cache); -int _Py_Specialize_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, SpecializedCacheEntry *cache); -int _Py_Specialize_BinarySubscr(PyObject *sub, PyObject *container, _Py_CODEUNIT *instr, SpecializedCacheEntry *cache); -int _Py_Specialize_StoreSubscr(PyObject *container, PyObject *sub, _Py_CODEUNIT *instr); -int _Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, +extern int _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, SpecializedCacheEntry *cache); +extern int _Py_Specialize_StoreAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, SpecializedCacheEntry *cache); +extern int _Py_Specialize_LoadGlobal(PyObject *globals, PyObject *builtins, _Py_CODEUNIT *instr, PyObject *name, SpecializedCacheEntry *cache); +extern int _Py_Specialize_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, SpecializedCacheEntry *cache); +extern int _Py_Specialize_BinarySubscr(PyObject *sub, PyObject *container, _Py_CODEUNIT *instr, SpecializedCacheEntry *cache); +extern int _Py_Specialize_StoreSubscr(PyObject *container, PyObject *sub, _Py_CODEUNIT *instr); +extern int _Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, PyObject *kwnames, SpecializedCacheEntry *cache); -int _Py_Specialize_Precall(PyObject *callable, _Py_CODEUNIT *instr, int nargs, +extern int _Py_Specialize_Precall(PyObject *callable, _Py_CODEUNIT *instr, int nargs, PyObject *kwnames, SpecializedCacheEntry *cache, PyObject *builtins); -void _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr, +extern void _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr, int oparg); -void _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr, SpecializedCacheEntry *cache); -void _Py_Specialize_UnpackSequence(PyObject *seq, _Py_CODEUNIT *instr, +extern void _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr, SpecializedCacheEntry *cache); +extern void _Py_Specialize_UnpackSequence(PyObject *seq, _Py_CODEUNIT *instr, SpecializedCacheEntry *cache); /* Deallocator function for static codeobjects used in deepfreeze.py */ -void _PyStaticCode_Dealloc(PyCodeObject *co); +extern void _PyStaticCode_Dealloc(PyCodeObject *co); /* Function to intern strings of codeobjects */ -void _PyStaticCode_InternStrings(PyCodeObject *co); +extern void _PyStaticCode_InternStrings(PyCodeObject *co); #ifdef Py_STATS @@ -343,9 +369,9 @@ extern PyStats _py_stats; #define CALL_STAT_INC(name) _py_stats.call_stats.name++ #define OBJECT_STAT_INC(name) _py_stats.object_stats.name++ -void _Py_PrintSpecializationStats(int to_file); +extern void _Py_PrintSpecializationStats(int to_file); -PyAPI_FUNC(PyObject*) _Py_GetSpecializationStats(void); +extern PyObject* _Py_GetSpecializationStats(void); #else #define STAT_INC(opname, name) ((void)0) |