Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
bpo-46841: Use inline caching for calls#31709
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 ourterms of service andprivacy 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 fromall commits
2820d50cb7dbeaca72a9959ad3edba214fcc5d69228f21380d9480d22021895File 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 |
|---|---|---|
| @@ -8,50 +8,10 @@ extern "C" { | ||
| * Specialization and quickening structs and helper functions | ||
| */ | ||
| // Inline caches. If you change the number of cache entries for an instruction, | ||
| // you must *also* update the number of cache entries in Lib/opcode.py and bump | ||
| // the magic number in Lib/importlib/_bootstrap_external.py! | ||
| #define CACHE_ENTRIES(cache) (sizeof(cache)/sizeof(_Py_CODEUNIT)) | ||
| @@ -112,73 +72,22 @@ typedef struct { | ||
| #define INLINE_CACHE_ENTRIES_LOAD_METHOD CACHE_ENTRIES(_PyLoadMethodCache) | ||
| typedef struct { | ||
| _Py_CODEUNIT counter; | ||
| _Py_CODEUNIT func_version[2]; | ||
| _Py_CODEUNIT min_args; | ||
| } _PyCallCache; | ||
| #define INLINE_CACHE_ENTRIES_CALL CACHE_ENTRIES(_PyCallCache) | ||
| typedef struct { | ||
| _Py_CODEUNIT counter; | ||
| } _PyPrecallCache; | ||
| #define INLINE_CACHE_ENTRIES_PRECALL CACHE_ENTRIES(_PyPrecallCache) | ||
| /* Maximum size of code to quicken, in code units. */ | ||
| #define MAX_SIZE_TO_QUICKEN 10000 | ||
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. Is this just to get the unpack sequence benchmark to work again, or something else? 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. Nope, just for | ||
| #define QUICKENING_WARMUP_DELAY 8 | ||
| @@ -205,6 +114,13 @@ _Py_IncrementCountAndMaybeQuicken(PyCodeObject *code) | ||
| extern Py_ssize_t _Py_QuickenedCount; | ||
| // Borrowed references to common callables: | ||
| struct callable_cache { | ||
| PyObject *isinstance; | ||
| PyObject *len; | ||
| PyObject *list_append; | ||
| }; | ||
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. I think the existence of I'm happy to leave it as is for now, though. We should look to make the whole struct static, although the mutability of builtin functions makes that tricky for 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. I believe each interpreter has its own | ||
| /* "Locals plus" for a code object is the set of locals + cell vars + | ||
| * free vars. This relates to variable names as well as offsets into | ||
| * the "fast locals" storage array of execution frames. The compiler | ||
| @@ -332,11 +248,6 @@ extern int _PyLineTable_PreviousAddressRange(PyCodeAddressRange *range); | ||
| #define ADAPTIVE_CACHE_BACKOFF 64 | ||
| /* Specialization functions */ | ||
| extern int _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, | ||
| @@ -348,10 +259,10 @@ extern int _Py_Specialize_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr, | ||
| PyObject *name); | ||
| extern int _Py_Specialize_BinarySubscr(PyObject *sub, PyObject *container, _Py_CODEUNIT *instr); | ||
| 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); | ||
| extern int _Py_Specialize_Precall(PyObject *callable, _Py_CODEUNIT *instr, | ||
| int nargs, PyObject *kwnames, int oparg); | ||
| extern void _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr, | ||
| int oparg); | ||
| extern void _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs, | ||
Uh oh!
There was an error while loading.Please reload this page.