diff options
author | Mark Shannon <mark@hotpy.org> | 2021-12-01 12:09:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-01 12:09:36 (GMT) |
commit | 49444fb807ecb396462c8e5f547eeb5c6bc5d4de (patch) | |
tree | 9b42fa9128a1f22da7e7a95b696a5a40ace1515a /Include/internal | |
parent | 0aa0bd056349f73de9577ccc38560c1d01864d51 (diff) | |
download | cpython-49444fb807ecb396462c8e5f547eeb5c6bc5d4de.zip cpython-49444fb807ecb396462c8e5f547eeb5c6bc5d4de.tar.gz cpython-49444fb807ecb396462c8e5f547eeb5c6bc5d4de.tar.bz2 |
bpo-45753: Interpreter internal tweaks (GH-29575)
* Split exit paths into exceptional and non-exceptional.
* Move exit tracing code to individual bytecodes.
* Wrap all trace entry and exit events in macros to make them clearer and easier to enhance.
* Move return sequence into RETURN_VALUE, YIELD_VALUE and YIELD_FROM. Distinguish between normal trace events and dtrace events.
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 */ |