Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-120642: Move private PyCode APIs to the internal C API#120643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
118f88f7e4f175711cdc00788b3c464fc8d5588b7a3f73bf31e8a1c0File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -24,58 +24,6 @@ typedef struct _Py_GlobalMonitors{ | ||
| uint8_t tools[_PY_MONITORING_UNGROUPED_EVENTS]; | ||
| } _Py_GlobalMonitors; | ||
| typedef struct{ | ||
| union{ | ||
| struct{ | ||
| uint16_t backoff : 4; | ||
| uint16_t value : 12; | ||
| }; | ||
| uint16_t as_counter; // For printf("%#x", ...) | ||
| }; | ||
| } _Py_BackoffCounter; | ||
| /* Each instruction in a code object is a fixed-width value, | ||
| * currently 2 bytes: 1-byte opcode + 1-byte oparg. The EXTENDED_ARG | ||
| * opcode allows for larger values but the current limit is 3 uses | ||
| * of EXTENDED_ARG (see Python/compile.c), for a maximum | ||
| * 32-bit value. This aligns with the note in Python/compile.c | ||
| * (compiler_addop_i_line) indicating that the max oparg value is | ||
| * 2**32 - 1, rather than INT_MAX. | ||
| */ | ||
| typedef union{ | ||
| uint16_t cache; | ||
| struct{ | ||
| uint8_t code; | ||
| uint8_t arg; | ||
| } op; | ||
| _Py_BackoffCounter counter; // First cache entry of specializable op | ||
| } _Py_CODEUNIT; | ||
Fidget-Spinner marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| /* These macros only remain defined for compatibility. */ | ||
| #define _Py_OPCODE(word) ((word).op.code) | ||
| #define _Py_OPARG(word) ((word).op.arg) | ||
| static inline _Py_CODEUNIT | ||
| _py_make_codeunit(uint8_t opcode, uint8_t oparg) | ||
| { | ||
| // No designated initialisers because of C++ compat | ||
| _Py_CODEUNIT word; | ||
| word.op.code = opcode; | ||
| word.op.arg = oparg; | ||
| return word; | ||
| } | ||
| static inline void | ||
| _py_set_opcode(_Py_CODEUNIT *word, uint8_t opcode) | ||
| { | ||
| word->op.code = opcode; | ||
| } | ||
| #define _Py_MAKE_CODEUNIT(opcode, oparg) _py_make_codeunit((opcode), (oparg)) | ||
| #define _Py_SET_OPCODE(word, opcode) _py_set_opcode(&(word), (opcode)) | ||
| typedef struct{ | ||
| PyObject *_co_code; | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -9,6 +9,50 @@ extern "C"{ | ||
| #endif | ||
| #include "pycore_lock.h" // PyMutex | ||
| #include "pycore_backoff.h" // _Py_BackoffCounter | ||
| /* Each instruction in a code object is a fixed-width value, | ||
| * currently 2 bytes: 1-byte opcode + 1-byte oparg. The EXTENDED_ARG | ||
| * opcode allows for larger values but the current limit is 3 uses | ||
| * of EXTENDED_ARG (see Python/compile.c), for a maximum | ||
| * 32-bit value. This aligns with the note in Python/compile.c | ||
| * (compiler_addop_i_line) indicating that the max oparg value is | ||
| * 2**32 - 1, rather than INT_MAX. | ||
| */ | ||
| typedef union{ | ||
| uint16_t cache; | ||
| struct{ | ||
| uint8_t code; | ||
| uint8_t arg; | ||
| } op; | ||
| _Py_BackoffCounter counter; // First cache entry of specializable op | ||
| } _Py_CODEUNIT; | ||
| /* These macros only remain defined for compatibility. */ | ||
| #define _Py_OPCODE(word) ((word).op.code) | ||
| #define _Py_OPARG(word) ((word).op.arg) | ||
| static inline _Py_CODEUNIT | ||
| _py_make_codeunit(uint8_t opcode, uint8_t oparg) | ||
| { | ||
| // No designated initialisers because of C++ compat | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an internal header. Why does it need to be C++ compatible? MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No idea, I just moved code. For now, I prefer to leave it as it is. I can be reworked later. | ||
| _Py_CODEUNIT word; | ||
| word.op.code = opcode; | ||
| word.op.arg = oparg; | ||
| return word; | ||
| } | ||
| static inline void | ||
| _py_set_opcode(_Py_CODEUNIT *word, uint8_t opcode) | ||
| { | ||
| word->op.code = opcode; | ||
| } | ||
| #define _Py_MAKE_CODEUNIT(opcode, oparg) _py_make_codeunit((opcode), (oparg)) | ||
| #define _Py_SET_OPCODE(word, opcode) _py_set_opcode(&(word), (opcode)) | ||
| // We hide some of the newer PyCodeObject fields behind macros. | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.