thautwarm / diojit

Fully compatible CPython jit compiler. Optimising Dynamic, Interpreted, and Object-oriented(DIO) programs.
BSD 2-Clause "Simplified" License
117 stars 2 forks source link

codegen: working with python exceptions #9

Closed thautwarm closed 3 years ago

thautwarm commented 3 years ago

when specialising, primitives like getattr(a, "attr") will be translated to PyObject_GetAttr(...) or PyObject_GetAttrString() or dynjit_get_member_by_offset(...), which might return NULL and can work with cython exception system.

can achieve this via

cdef extern from "":
    """
    static inline void* dynjit_py_err(){
        return NULL;
    }
    """
    object dynjit_py_err()
thautwarm commented 3 years ago

leveraging except keyword does this work. https://github.com/thautwarm/dynjit/blob/e614b363fd882e28953246f5e7be7d030e162f99/jit/ll/infr.pxd#L58