diff options
Diffstat (limited to 'Include/internal')
-rw-r--r-- | Include/internal/pycore_code.h | 23 | ||||
-rw-r--r-- | Include/internal/pycore_frame.h | 5 |
2 files changed, 17 insertions, 11 deletions
diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h index 194af46..d4d1392 100644 --- a/Include/internal/pycore_code.h +++ b/Include/internal/pycore_code.h @@ -137,24 +137,25 @@ _GetSpecializedCacheEntryForInstruction(const _Py_CODEUNIT *first_instr, int nex #define QUICKENING_INITIAL_WARMUP_VALUE (-QUICKENING_WARMUP_DELAY) #define QUICKENING_WARMUP_COLDEST 1 -static inline void -PyCodeObject_IncrementWarmup(PyCodeObject * co) -{ - co->co_warmup++; -} +int _Py_Quicken(PyCodeObject *code); -/* Used by the interpreter to determine when a code object should be quickened */ +/* Returns 1 if quickening occurs. + * -1 if an error occurs + * 0 otherwise */ static inline int -PyCodeObject_IsWarmedUp(PyCodeObject * co) +_Py_IncrementCountAndMaybeQuicken(PyCodeObject *code) { - return (co->co_warmup == 0); + if (code->co_warmup != 0) { + code->co_warmup++; + if (code->co_warmup == 0) { + return _Py_Quicken(code) ? -1 : 1; + } + } + return 0; } -int _Py_Quicken(PyCodeObject *code); - extern Py_ssize_t _Py_QuickenedCount; - /* "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 diff --git a/Include/internal/pycore_frame.h b/Include/internal/pycore_frame.h index 0015de8..b0e51a6 100644 --- a/Include/internal/pycore_frame.h +++ b/Include/internal/pycore_frame.h @@ -19,6 +19,11 @@ enum _framestate { typedef signed char PyFrameState; +/* + frame->f_lasti refers to the index of the last instruction, + unless it's -1 in which case next_instr should be first_instr. +*/ + typedef struct _interpreter_frame { PyFunctionObject *f_func; /* Strong reference */ PyObject *f_globals; /* Borrowed reference */ |