Lines Matching refs:co
124 PyCodeObject *co; in PyCode_NewWithPosOnlyArgs() local
231 co = PyObject_New(PyCodeObject, &PyCode_Type); in PyCode_NewWithPosOnlyArgs()
232 if (co == NULL) { in PyCode_NewWithPosOnlyArgs()
237 co->co_argcount = argcount; in PyCode_NewWithPosOnlyArgs()
238 co->co_posonlyargcount = posonlyargcount; in PyCode_NewWithPosOnlyArgs()
239 co->co_kwonlyargcount = kwonlyargcount; in PyCode_NewWithPosOnlyArgs()
240 co->co_nlocals = nlocals; in PyCode_NewWithPosOnlyArgs()
241 co->co_stacksize = stacksize; in PyCode_NewWithPosOnlyArgs()
242 co->co_flags = flags; in PyCode_NewWithPosOnlyArgs()
244 co->co_code = code; in PyCode_NewWithPosOnlyArgs()
246 co->co_consts = consts; in PyCode_NewWithPosOnlyArgs()
248 co->co_names = names; in PyCode_NewWithPosOnlyArgs()
250 co->co_varnames = varnames; in PyCode_NewWithPosOnlyArgs()
252 co->co_freevars = freevars; in PyCode_NewWithPosOnlyArgs()
254 co->co_cellvars = cellvars; in PyCode_NewWithPosOnlyArgs()
255 co->co_cell2arg = cell2arg; in PyCode_NewWithPosOnlyArgs()
257 co->co_filename = filename; in PyCode_NewWithPosOnlyArgs()
259 co->co_name = name; in PyCode_NewWithPosOnlyArgs()
260 co->co_firstlineno = firstlineno; in PyCode_NewWithPosOnlyArgs()
262 co->co_linetable = linetable; in PyCode_NewWithPosOnlyArgs()
263 co->co_zombieframe = NULL; in PyCode_NewWithPosOnlyArgs()
264 co->co_weakreflist = NULL; in PyCode_NewWithPosOnlyArgs()
265 co->co_extra = NULL; in PyCode_NewWithPosOnlyArgs()
267 co->co_opcache_map = NULL; in PyCode_NewWithPosOnlyArgs()
268 co->co_opcache = NULL; in PyCode_NewWithPosOnlyArgs()
269 co->co_opcache_flag = 0; in PyCode_NewWithPosOnlyArgs()
270 co->co_opcache_size = 0; in PyCode_NewWithPosOnlyArgs()
271 return co; in PyCode_NewWithPosOnlyArgs()
289 _PyCode_InitOpcache(PyCodeObject *co) in _PyCode_InitOpcache() argument
291 Py_ssize_t co_size = PyBytes_Size(co->co_code) / sizeof(_Py_CODEUNIT); in _PyCode_InitOpcache()
292 co->co_opcache_map = (unsigned char *)PyMem_Calloc(co_size, 1); in _PyCode_InitOpcache()
293 if (co->co_opcache_map == NULL) { in _PyCode_InitOpcache()
297 const _Py_CODEUNIT *opcodes = (_Py_CODEUNIT*)PyBytes_AS_STRING(co->co_code); in _PyCode_InitOpcache()
307 co->co_opcache_map[i] = (unsigned char)opts; in _PyCode_InitOpcache()
315 co->co_opcache = (_PyOpcache *)PyMem_Calloc(opts, sizeof(_PyOpcache)); in _PyCode_InitOpcache()
316 if (co->co_opcache == NULL) { in _PyCode_InitOpcache()
317 PyMem_Free(co->co_opcache_map); in _PyCode_InitOpcache()
322 PyMem_Free(co->co_opcache_map); in _PyCode_InitOpcache()
323 co->co_opcache_map = NULL; in _PyCode_InitOpcache()
324 co->co_opcache = NULL; in _PyCode_InitOpcache()
327 co->co_opcache_size = (unsigned char)opts; in _PyCode_InitOpcache()
557 PyObject *co = NULL; in code_new_impl() local
615 co = (PyObject *)PyCode_NewWithPosOnlyArgs(argcount, posonlyargcount, in code_new_impl()
627 return co; in code_new_impl()
631 code_dealloc(PyCodeObject *co) in code_dealloc() argument
633 if (co->co_opcache != NULL) { in code_dealloc()
634 PyMem_Free(co->co_opcache); in code_dealloc()
636 if (co->co_opcache_map != NULL) { in code_dealloc()
637 PyMem_Free(co->co_opcache_map); in code_dealloc()
639 co->co_opcache_flag = 0; in code_dealloc()
640 co->co_opcache_size = 0; in code_dealloc()
642 if (co->co_extra != NULL) { in code_dealloc()
644 _PyCodeObjectExtra *co_extra = co->co_extra; in code_dealloc()
657 Py_XDECREF(co->co_code); in code_dealloc()
658 Py_XDECREF(co->co_consts); in code_dealloc()
659 Py_XDECREF(co->co_names); in code_dealloc()
660 Py_XDECREF(co->co_varnames); in code_dealloc()
661 Py_XDECREF(co->co_freevars); in code_dealloc()
662 Py_XDECREF(co->co_cellvars); in code_dealloc()
663 Py_XDECREF(co->co_filename); in code_dealloc()
664 Py_XDECREF(co->co_name); in code_dealloc()
665 Py_XDECREF(co->co_linetable); in code_dealloc()
666 if (co->co_cell2arg != NULL) in code_dealloc()
667 PyMem_Free(co->co_cell2arg); in code_dealloc()
668 if (co->co_zombieframe != NULL) in code_dealloc()
669 PyObject_GC_Del(co->co_zombieframe); in code_dealloc()
670 if (co->co_weakreflist != NULL) in code_dealloc()
671 PyObject_ClearWeakRefs((PyObject*)co); in code_dealloc()
672 PyObject_Free(co); in code_dealloc()
676 code_sizeof(PyCodeObject *co, PyObject *Py_UNUSED(args)) in code_sizeof() argument
678 Py_ssize_t res = _PyObject_SIZE(Py_TYPE(co)); in code_sizeof()
679 _PyCodeObjectExtra *co_extra = (_PyCodeObjectExtra*) co->co_extra; in code_sizeof()
681 if (co->co_cell2arg != NULL && co->co_cellvars != NULL) { in code_sizeof()
682 res += PyTuple_GET_SIZE(co->co_cellvars) * sizeof(Py_ssize_t); in code_sizeof()
688 if (co->co_opcache != NULL) { in code_sizeof()
689 assert(co->co_opcache_map != NULL); in code_sizeof()
691 res += PyBytes_GET_SIZE(co->co_code) / sizeof(_Py_CODEUNIT); in code_sizeof()
693 res += co->co_opcache_size * sizeof(_PyOpcache); in code_sizeof()
765 code_repr(PyCodeObject *co) in code_repr() argument
768 if (co->co_firstlineno != 0) in code_repr()
769 lineno = co->co_firstlineno; in code_repr()
772 if (co->co_filename && PyUnicode_Check(co->co_filename)) { in code_repr()
775 co->co_name, co, co->co_filename, lineno); in code_repr()
779 co->co_name, co, lineno); in code_repr()
916 PyCodeObject *co, *cp; in code_richcompare() local
927 co = (PyCodeObject *)self; in code_richcompare()
930 eq = PyObject_RichCompareBool(co->co_name, cp->co_name, Py_EQ); in code_richcompare()
932 eq = co->co_argcount == cp->co_argcount; in code_richcompare()
934 eq = co->co_posonlyargcount == cp->co_posonlyargcount; in code_richcompare()
936 eq = co->co_kwonlyargcount == cp->co_kwonlyargcount; in code_richcompare()
938 eq = co->co_nlocals == cp->co_nlocals; in code_richcompare()
940 eq = co->co_flags == cp->co_flags; in code_richcompare()
942 eq = co->co_firstlineno == cp->co_firstlineno; in code_richcompare()
944 eq = PyObject_RichCompareBool(co->co_code, cp->co_code, Py_EQ); in code_richcompare()
948 consts1 = _PyCode_ConstantKey(co->co_consts); in code_richcompare()
961 eq = PyObject_RichCompareBool(co->co_names, cp->co_names, Py_EQ); in code_richcompare()
963 eq = PyObject_RichCompareBool(co->co_varnames, cp->co_varnames, Py_EQ); in code_richcompare()
965 eq = PyObject_RichCompareBool(co->co_freevars, cp->co_freevars, Py_EQ); in code_richcompare()
967 eq = PyObject_RichCompareBool(co->co_cellvars, cp->co_cellvars, Py_EQ); in code_richcompare()
990 code_hash(PyCodeObject *co) in code_hash() argument
993 h0 = PyObject_Hash(co->co_name); in code_hash()
995 h1 = PyObject_Hash(co->co_code); in code_hash()
997 h2 = PyObject_Hash(co->co_consts); in code_hash()
999 h3 = PyObject_Hash(co->co_names); in code_hash()
1001 h4 = PyObject_Hash(co->co_varnames); in code_hash()
1003 h5 = PyObject_Hash(co->co_freevars); in code_hash()
1005 h6 = PyObject_Hash(co->co_cellvars); in code_hash()
1008 co->co_argcount ^ co->co_posonlyargcount ^ co->co_kwonlyargcount ^ in code_hash()
1009 co->co_nlocals ^ co->co_flags; in code_hash()
1246 PyCode_Addr2Line(PyCodeObject *co, int addrq) in PyCode_Addr2Line() argument
1249 return co->co_firstlineno; in PyCode_Addr2Line()
1251 assert(addrq >= 0 && addrq < PyBytes_GET_SIZE(co->co_code)); in PyCode_Addr2Line()
1253 _PyCode_InitAddressRange(co, &bounds); in PyCode_Addr2Line()
1269 _PyCode_InitAddressRange(PyCodeObject* co, PyCodeAddressRange *bounds) in _PyCode_InitAddressRange() argument
1271 const char *linetable = PyBytes_AS_STRING(co->co_linetable); in _PyCode_InitAddressRange()
1272 Py_ssize_t length = PyBytes_GET_SIZE(co->co_linetable); in _PyCode_InitAddressRange()
1273 PyLineTable_InitAddressRange(linetable, length, co->co_firstlineno, bounds); in _PyCode_InitAddressRange()