From adcd2205565f91c6719f4141ab4e1da6d7086126 Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Fri, 7 May 2021 15:19:19 +0100 Subject: bpo-40222: "Zero cost" exception handling (GH-25729) "Zero cost" exception handling. * Uses a lookup table to determine how to handle exceptions. * Removes SETUP_FINALLY and POP_TOP block instructions, eliminating (most of) the runtime overhead of try statements. * Reduces the size of the frame object by about 60%. --- Include/cpython/code.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Include/cpython/code.h') diff --git a/Include/cpython/code.h b/Include/cpython/code.h index e810eb4f81..330f1f54d1 100644 --- a/Include/cpython/code.h +++ b/Include/cpython/code.h @@ -40,6 +40,7 @@ struct PyCodeObject { PyObject *co_name; /* unicode (name, for reference) */ PyObject *co_linetable; /* string (encoding addr<->lineno mapping) See Objects/lnotab_notes.txt for details. */ + PyObject *co_exceptiontable; /* Byte string encoding exception handling table */ void *co_zombieframe; /* for optimization only (see frameobject.c) */ PyObject *co_weakreflist; /* to support weakrefs to code objects */ /* Scratch space for extra data relating to the code object. @@ -117,12 +118,12 @@ PyAPI_DATA(PyTypeObject) PyCode_Type; PyAPI_FUNC(PyCodeObject *) PyCode_New( int, int, int, int, int, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, - PyObject *, PyObject *, int, PyObject *); + PyObject *, PyObject *, int, PyObject *, PyObject *); PyAPI_FUNC(PyCodeObject *) PyCode_NewWithPosOnlyArgs( int, int, int, int, int, int, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, - PyObject *, PyObject *, int, PyObject *); + PyObject *, PyObject *, int, PyObject *, PyObject *); /* same as struct above */ /* Creates a new empty code object with the specified source location. */ -- cgit v1.2.1