From 82df8c914a1e3a335f38c7797b8861110f61d9e9 Mon Sep 17 00:00:00 2001 From: stepan Date: Fri, 2 Dec 2022 16:14:54 +0100 Subject: [PATCH] Multiphase module initialization Make the multiphase module initialization the only way to initialize HPy modules, abandons the previous single phase initialization. HPy_MODINIT takes name of the extesion, so that it can generate PyInit_XXX for CPython, and HPyModuleDef. There is no user provided init function anymore. The runtime initializes the module and if the user wants to populate the module, or do any other initialization, they can define one or more HPy_mod_exec slots that are called by the runtime right after the module is created. The slots are defined in the same way as slots for types: by using HPyDef_SLOT macro. As a consequence, `HPy_MODINIT(myextension, hpydef)` is all that is necessary if the module only exposes module functions. Users can also define `HPy_mod_create` slot, similar to CPython's `Py_mod_create`, but in HPy this slot can return only objects that are not of the builtin module type. The reasoning is that builtin module objects can be created by the runtime from `HPyModuleDef` and, for the time being, there is no use-case for manually creating builtin module objects in the `HPy_mod_create` slot or anywhere else. If such a use-case emerges, support for it can be easily added to HPy. If user specifies the `HPy_mod_create slot`, specifying anything else (setting it to a non-default value) in `HPyModuleDef` is an error. Removes `HPyModule_Create` API/ABI function. The CPython equivalent `PyModule_Create` works only for single phase module initialization. We may add equivalents of `PyModule_FromDefAndSpec` to allow manual module creation if there is a use-case. Additionally, removes the CPython semantics of negative `m_size`. HPy will add other more explicit means to communicate subinterpreters support. --- docs/examples/mixed-example/mixed.c | 13 +- docs/examples/simple-example/simple.c | 8 +- docs/examples/snippets/hpyvarargs.c | 10 +- docs/examples/snippets/snippets.c | 8 +- .../steps/step_01_hpy_legacy.c | 44 +- .../steps/step_02_hpy_legacy.c | 32 +- .../porting-example/steps/step_03_hpy_final.c | 29 +- gdb-py.test | 2 +- hpy/debug/src/_debugmod.c | 31 +- hpy/debug/src/autogen_debug_ctx_init.h | 2 - hpy/debug/src/autogen_debug_wrappers.c | 5 - hpy/debug/src/debug_ctx_cpython.c | 13 + hpy/debug/src/include/hpy_debug.h | 8 +- .../include/hpy/autogen_hpyfunc_declare.h | 2 + hpy/devel/include/hpy/autogen_hpyslot.h | 4 + hpy/devel/include/hpy/cpy_types.h | 2 + .../include/hpy/cpython/hpyfunc_trampolines.h | 12 + hpy/devel/include/hpy/hpyfunc.h | 2 + hpy/devel/include/hpy/hpymodule.h | 72 +- hpy/devel/include/hpy/runtime/ctx_module.h | 25 + hpy/devel/include/hpy/universal/autogen_ctx.h | 1 - .../hpy/universal/autogen_trampolines.h | 4 - .../hpy/universal/hpyfunc_trampolines.h | 15 + hpy/devel/src/runtime/ctx_module.c | 138 +++- hpy/tools/autogen/hpyfunc.py | 10 +- hpy/tools/autogen/public_api.h | 360 +++++----- hpy/trace/src/_tracemod.c | 10 +- hpy/trace/src/autogen_trace_ctx_init.h | 6 +- hpy/trace/src/autogen_trace_func_table.c | 5 +- hpy/trace/src/autogen_trace_wrappers.c | 665 +++++++++--------- hpy/trace/src/include/hpy_trace.h | 8 +- hpy/universal/src/autogen_ctx_def.h | 1 - hpy/universal/src/ctx_meth.c | 8 + hpy/universal/src/hpymodule.c | 156 ++-- proof-of-concept/pof.c | 30 +- proof-of-concept/pofcpp.cpp | 30 +- proof-of-concept/pofpackage/bar.cpp | 13 +- proof-of-concept/pofpackage/foo.c | 13 +- test/support.py | 43 +- test/test_hpymodule.py | 289 +++++++- 40 files changed, 1317 insertions(+), 812 deletions(-) create mode 100644 hpy/devel/include/hpy/runtime/ctx_module.h diff --git a/docs/examples/mixed-example/mixed.c b/docs/examples/mixed-example/mixed.c index d5db36f8c..c5c04e4fc 100644 --- a/docs/examples/mixed-example/mixed.c +++ b/docs/examples/mixed-example/mixed.c @@ -39,20 +39,11 @@ static PyMethodDef py_defines[] = { }; static HPyModuleDef moduledef = { - .name = "mixed", .doc = "HPy Example of mixing CPython API and HPy API", - .size = -1, + .size = 0, .defines = hpy_defines, .legacy_methods = py_defines }; -HPy_MODINIT(mixed) -static HPy init_mixed_impl(HPyContext *ctx) -{ - HPy m; - m = HPyModule_Create(ctx, &moduledef); - if (HPy_IsNull(m)) - return HPy_NULL; - return m; -} +HPy_MODINIT(mixed, moduledef) diff --git a/docs/examples/simple-example/simple.c b/docs/examples/simple-example/simple.c index 4d9b94550..49883a950 100644 --- a/docs/examples/simple-example/simple.c +++ b/docs/examples/simple-example/simple.c @@ -31,17 +31,13 @@ static HPyDef *SimpleMethods[] = { }; static HPyModuleDef simple = { - .name = "simple", .doc = "HPy Example", - .size = -1, + .size = 0, .defines = SimpleMethods, .legacy_methods = NULL }; // END: methodsdef // BEGIN: moduledef -HPy_MODINIT(simple) -HPy init_simple_impl(HPyContext *ctx) { - return HPyModule_Create(ctx, &simple); -} +HPy_MODINIT(simple, simple) // END: moduledef \ No newline at end of file diff --git a/docs/examples/snippets/hpyvarargs.c b/docs/examples/snippets/hpyvarargs.c index 1a616eb35..e67c600dc 100644 --- a/docs/examples/snippets/hpyvarargs.c +++ b/docs/examples/snippets/hpyvarargs.c @@ -36,14 +36,10 @@ static HPyDef *SimpleMethods[] = { }; // END: methodsdef -static HPyModuleDef simple = { - .name = "hpyvarargs", +static HPyModuleDef def = { .doc = "HPy Example of varargs calling convention", - .size = -1, + .size = 0, .defines = SimpleMethods }; -HPy_MODINIT(hpyvarargs) -HPy init_hpyvarargs_impl(HPyContext *ctx) { - return HPyModule_Create(ctx, &simple); -} +HPy_MODINIT(hpyvarargs, def) diff --git a/docs/examples/snippets/snippets.c b/docs/examples/snippets/snippets.c index 6790d4ac1..fa926d09e 100644 --- a/docs/examples/snippets/snippets.c +++ b/docs/examples/snippets/snippets.c @@ -73,13 +73,9 @@ static HPyDef *Methods[] = { }; static HPyModuleDef snippets = { - .name = "snippets", .doc = "Various HPy code snippets for the docs", - .size = -1, + .size = 0, .defines = Methods }; -HPy_MODINIT(snippets) -HPy init_snippets_impl(HPyContext *ctx) { - return HPyModule_Create(ctx, &snippets); -} +HPy_MODINIT(snippets, snippets) diff --git a/docs/porting-example/steps/step_01_hpy_legacy.c b/docs/porting-example/steps/step_01_hpy_legacy.c index 2578944db..a31313251 100644 --- a/docs/porting-example/steps/step_01_hpy_legacy.c +++ b/docs/porting-example/steps/step_01_hpy_legacy.c @@ -149,30 +149,40 @@ static PyMethodDef PointModuleLegacyMethods[] = { {NULL, NULL, 0, NULL} }; -// HPy module methods (no methods have been ported yet) +// HPy supports only multiphase module initialization, so we must migrate the +// single phase initialization by extracting the code that populates the module +// object with attributes into a separate 'exec' slot. The module is not +// created manually by calling API like PyModule_Create, but the runtime creates +// the module for us from the specification in HPyModuleDef, and we can provide +// additional slots to populate the module before its initialization is finalized +HPyDef_SLOT(module_exec, HPy_mod_exec) +static int module_exec_impl(HPyContext *ctx, HPy mod) +{ + HPy point_type = HPyType_FromSpec(ctx, &Point_Type_spec, NULL); + if (HPy_IsNull(point_type)) + return -1; + HPy_SetAttr_s(ctx, mod, "Point", point_type); + return 0; +} + +// HPy module methods: no regular methods have been ported yet, +// but we add the module execute slot static HPyDef *module_defines[] = { + &module_exec, NULL }; static HPyModuleDef moduledef = { - .name = "step_01_hpy_legacy", + // .name = "step_01_hpy_legacy", + // ^-- .name is not needed for multiphase module initialization, + // it is always taken from the ModuleSpec .doc = "Point module (Step 1; All legacy methods)", - .size = -1, + .size = 0, .legacy_methods = PointModuleLegacyMethods, .defines = module_defines, }; -HPy_MODINIT(step_01_hpy_legacy) -static HPy init_step_01_hpy_legacy_impl(HPyContext *ctx) -{ - HPy m = HPyModule_Create(ctx, &moduledef); - if (HPy_IsNull(m)) - return HPy_NULL; - - HPy point_type = HPyType_FromSpec(ctx, &Point_Type_spec, NULL); - if (HPy_IsNull(point_type)) - return HPy_NULL; - HPy_SetAttr_s(ctx, m, "Point", point_type); - - return m; -} +// HPy_MODINIT takes the extension name, i.e., what would be XXX in PyInit_XXX, +// and the module definition. The module will be created by the runtime and +// passed to the HPy_mod_exec slots if any are defined +HPy_MODINIT(step_01_hpy_legacy, moduledef) diff --git a/docs/porting-example/steps/step_02_hpy_legacy.c b/docs/porting-example/steps/step_02_hpy_legacy.c index 3907c4477..bb4e43589 100644 --- a/docs/porting-example/steps/step_02_hpy_legacy.c +++ b/docs/porting-example/steps/step_02_hpy_legacy.c @@ -140,30 +140,28 @@ static PyMethodDef PointModuleLegacyMethods[] = { {NULL, NULL, 0, NULL} }; -// HPy module methods (no methods have been ported yet) +HPyDef_SLOT(module_exec, HPy_mod_exec) +static int module_exec_impl(HPyContext *ctx, HPy mod) +{ + HPy point_type = HPyType_FromSpec(ctx, &Point_Type_spec, NULL); + if (HPy_IsNull(point_type)) + return -1; + HPy_SetAttr_s(ctx, mod, "Point", point_type); + return 0; +} + +// HPy module methods: no regular methods have been ported yet, +// but we add the module execute slot static HPyDef *module_defines[] = { + &module_exec, NULL }; static HPyModuleDef moduledef = { - .name = "step_02_hpy_legacy", .doc = "Point module (Step 2; Porting some methods)", - .size = -1, + .size = 0, .legacy_methods = PointModuleLegacyMethods, .defines = module_defines, }; -HPy_MODINIT(step_02_hpy_legacy) -static HPy init_step_02_hpy_legacy_impl(HPyContext *ctx) -{ - HPy m = HPyModule_Create(ctx, &moduledef); - if (HPy_IsNull(m)) - return HPy_NULL; - - HPy point_type = HPyType_FromSpec(ctx, &Point_Type_spec, NULL); - if (HPy_IsNull(point_type)) - return HPy_NULL; - HPy_SetAttr_s(ctx, m, "Point", point_type); - - return m; -} +HPy_MODINIT(step_02_hpy_legacy, moduledef) diff --git a/docs/porting-example/steps/step_03_hpy_final.c b/docs/porting-example/steps/step_03_hpy_final.c index 9c2e9fa2a..2c9a3f5c0 100644 --- a/docs/porting-example/steps/step_03_hpy_final.c +++ b/docs/porting-example/steps/step_03_hpy_final.c @@ -125,30 +125,27 @@ static HPyType_Spec Point_Type_spec = { .defines = point_defines }; +HPyDef_SLOT(module_exec, HPy_mod_exec) +static int module_exec_impl(HPyContext *ctx, HPy mod) +{ + HPy point_type = HPyType_FromSpec(ctx, &Point_Type_spec, NULL); + if (HPy_IsNull(point_type)) + return -1; + HPy_SetAttr_s(ctx, mod, "Point", point_type); + return 0; +} + // HPy module methods static HPyDef *module_defines[] = { + &module_exec, &dot, NULL }; static HPyModuleDef moduledef = { - .name = "step_03_hpy_final", .doc = "Point module (Step 3; Porting complete)", - .size = -1, + .size = 0, .defines = module_defines, }; -HPy_MODINIT(step_03_hpy_final) -static HPy init_step_03_hpy_final_impl(HPyContext *ctx) -{ - HPy m = HPyModule_Create(ctx, &moduledef); - if (HPy_IsNull(m)) - return HPy_NULL; - - HPy point_type = HPyType_FromSpec(ctx, &Point_Type_spec, NULL); - if (HPy_IsNull(point_type)) - return HPy_NULL; - HPy_SetAttr_s(ctx, m, "Point", point_type); - - return m; -} +HPy_MODINIT(step_03_hpy_final, moduledef) diff --git a/gdb-py.test b/gdb-py.test index 7412a0621..63901b89c 100755 --- a/gdb-py.test +++ b/gdb-py.test @@ -1,3 +1,3 @@ #!/bin/bash -gdb --eval-command run --args python3 -m pytest -s "$@" +gdb -ex "set breakpoint pending on" -ex "b create_impl" --eval-command run --args python3 -m pytest -s "$@" diff --git a/hpy/debug/src/_debugmod.c b/hpy/debug/src/_debugmod.c index eeda96fb9..5333bf8e9 100644 --- a/hpy/debug/src/_debugmod.c +++ b/hpy/debug/src/_debugmod.c @@ -377,6 +377,17 @@ static UHPy new_DebugHandleObj(HPyContext *uctx, UHPy u_DebugHandleType, /* ~~~~~~ definition of the module hpy.debug._debug ~~~~~~~ */ +HPyDef_SLOT(module_exec, HPy_mod_exec) +static int module_exec_impl(HPyContext *uctx, HPy m) +{ + UHPy h_DebugHandleType = HPyType_FromSpec(uctx, &DebugHandleType_spec, NULL); + if (HPy_IsNull(h_DebugHandleType)) + return -1; + HPy_SetAttr_s(uctx, m, "DebugHandle", h_DebugHandleType); + HPy_Close(uctx, h_DebugHandleType); + return 0; +} + static HPyDef *module_defines[] = { &new_generation, &get_open_handles, @@ -387,28 +398,14 @@ static HPyDef *module_defines[] = { &set_protected_raw_data_max_size, &set_on_invalid_handle, &set_handle_stack_trace_limit, + &module_exec, NULL }; static HPyModuleDef moduledef = { - .name = "hpy.debug._debug", .doc = "HPy debug mode", - .size = -1, + .size = 0, .defines = module_defines }; - -HPy_MODINIT(_debug) -static UHPy init__debug_impl(HPyContext *uctx) -{ - UHPy m = HPyModule_Create(uctx, &moduledef); - if (HPy_IsNull(m)) - return HPy_NULL; - - UHPy h_DebugHandleType = HPyType_FromSpec(uctx, &DebugHandleType_spec, NULL); - if (HPy_IsNull(h_DebugHandleType)) - return HPy_NULL; - HPy_SetAttr_s(uctx, m, "DebugHandle", h_DebugHandleType); - HPy_Close(uctx, h_DebugHandleType); - return m; -} +HPy_MODINIT(_debug, moduledef) diff --git a/hpy/debug/src/autogen_debug_ctx_init.h b/hpy/debug/src/autogen_debug_ctx_init.h index 88251999c..8ee3b477a 100644 --- a/hpy/debug/src/autogen_debug_ctx_init.h +++ b/hpy/debug/src/autogen_debug_ctx_init.h @@ -10,7 +10,6 @@ */ -DHPy debug_ctx_Module_Create(HPyContext *dctx, HPyModuleDef *def); DHPy debug_ctx_Dup(HPyContext *dctx, DHPy h); void debug_ctx_Close(HPyContext *dctx, DHPy h); DHPy debug_ctx_Long_FromLong(HPyContext *dctx, long value); @@ -262,7 +261,6 @@ static inline void debug_ctx_init_fields(HPyContext *dctx, HPyContext *uctx) dctx->h_CapsuleType = DHPy_open_immortal(dctx, uctx->h_CapsuleType); dctx->h_SliceType = DHPy_open_immortal(dctx, uctx->h_SliceType); dctx->h_Builtins = DHPy_open_immortal(dctx, uctx->h_Builtins); - dctx->ctx_Module_Create = &debug_ctx_Module_Create; dctx->ctx_Dup = &debug_ctx_Dup; dctx->ctx_Close = &debug_ctx_Close; dctx->ctx_Long_FromLong = &debug_ctx_Long_FromLong; diff --git a/hpy/debug/src/autogen_debug_wrappers.c b/hpy/debug/src/autogen_debug_wrappers.c index 90d7e0c61..f847b2722 100644 --- a/hpy/debug/src/autogen_debug_wrappers.c +++ b/hpy/debug/src/autogen_debug_wrappers.c @@ -12,11 +12,6 @@ #include "debug_internal.h" -DHPy debug_ctx_Module_Create(HPyContext *dctx, HPyModuleDef *def) -{ - return DHPy_open(dctx, HPyModule_Create(get_info(dctx)->uctx, def)); -} - DHPy debug_ctx_Dup(HPyContext *dctx, DHPy h) { return DHPy_open(dctx, HPy_Dup(get_info(dctx)->uctx, DHPy_unwrap(dctx, h))); diff --git a/hpy/debug/src/debug_ctx_cpython.c b/hpy/debug/src/debug_ctx_cpython.c index ea81c7eda..e26d16d14 100644 --- a/hpy/debug/src/debug_ctx_cpython.c +++ b/hpy/debug/src/debug_ctx_cpython.c @@ -24,7 +24,9 @@ #include #include "debug_internal.h" #include "hpy/runtime/ctx_type.h" // for call_traverseproc_from_trampoline +#include "hpy/runtime/ctx_module.h" #include "handles.h" // for _py2h and _h2py + #if defined(_MSC_VER) # include /* for alloca() */ #endif @@ -193,6 +195,17 @@ void debug_ctx_CallRealFunctionFromTrampoline(HPyContext *dctx, PyCapsule_GetContext(capsule)); return; } + case HPyFunc_MOD_CREATE: { + HPyFunc_unaryfunc f = (HPyFunc_unaryfunc)func; + _HPyFunc_args_UNARYFUNC *a = (_HPyFunc_args_UNARYFUNC*)args; + DHPy dh_arg0 = _py2dh(dctx, a->arg0); + DHPy dh_result = f(dctx, dh_arg0); + DHPy_close_and_check(dctx, dh_arg0); + a->result = _dh2py(dctx, dh_result); + _HPyModule_CheckCreateSlotResult(&a->result); + DHPy_close(dctx, dh_result); + return; + } #include "autogen_debug_ctx_call.i" default: Py_FatalError("Unsupported HPyFunc_Signature in debug_ctx_cpython.c"); diff --git a/hpy/debug/src/include/hpy_debug.h b/hpy/debug/src/include/hpy_debug.h index b8caee682..f2fb9471b 100644 --- a/hpy/debug/src/include/hpy_debug.h +++ b/hpy/debug/src/include/hpy_debug.h @@ -46,6 +46,12 @@ void hpy_debug_close_handle(HPyContext *dctx, HPy dh); extern "C" #endif HPy_EXPORTED_SYMBOL -HPy HPyInit__debug(HPyContext *uctx); +HPyModuleDef* HPyInit__debug(); + +#ifdef ___cplusplus +extern "C" +#endif +HPy_EXPORTED_SYMBOL +void HPyInitGlobalContext__debug(HPyContext *ctx); #endif /* HPY_DEBUG_H */ diff --git a/hpy/devel/include/hpy/autogen_hpyfunc_declare.h b/hpy/devel/include/hpy/autogen_hpyfunc_declare.h index b506f7532..9ef2713d8 100644 --- a/hpy/devel/include/hpy/autogen_hpyfunc_declare.h +++ b/hpy/devel/include/hpy/autogen_hpyfunc_declare.h @@ -45,6 +45,7 @@ #define _HPyFunc_DECLARE_HPyFunc_TRAVERSEPROC(SYM) static int SYM(void *object, HPyFunc_visitproc visit, void *arg) #define _HPyFunc_DECLARE_HPyFunc_DESTRUCTOR(SYM) static void SYM(HPyContext *ctx, HPy) #define _HPyFunc_DECLARE_HPyFunc_DESTROYFUNC(SYM) static void SYM(void *) +#define _HPyFunc_DECLARE_HPyFunc_MOD_CREATE(SYM) static HPy SYM(HPyContext *ctx, HPy) typedef HPy (*HPyFunc_noargs)(HPyContext *ctx, HPy self); typedef HPy (*HPyFunc_o)(HPyContext *ctx, HPy self, HPy arg); @@ -81,3 +82,4 @@ typedef void (*HPyFunc_releasebufferproc)(HPyContext *ctx, HPy, HPy_buffer *); typedef int (*HPyFunc_traverseproc)(void *object, HPyFunc_visitproc visit, void *arg); typedef void (*HPyFunc_destructor)(HPyContext *ctx, HPy); typedef void (*HPyFunc_destroyfunc)(void *); +typedef HPy (*HPyFunc_mod_create)(HPyContext *ctx, HPy); diff --git a/hpy/devel/include/hpy/autogen_hpyslot.h b/hpy/devel/include/hpy/autogen_hpyslot.h index 599dfec2d..ba9729341 100644 --- a/hpy/devel/include/hpy/autogen_hpyslot.h +++ b/hpy/devel/include/hpy/autogen_hpyslot.h @@ -68,6 +68,8 @@ typedef enum { HPy_nb_inplace_matrix_multiply = 76, HPy_tp_finalize = 80, HPy_tp_destroy = 1000, + HPy_mod_create = 2000, + HPy_mod_exec = 2001, } HPySlot_Slot; #define _HPySlot_SIG__HPy_bf_getbuffer HPyFunc_GETBUFFERPROC @@ -127,3 +129,5 @@ typedef enum { #define _HPySlot_SIG__HPy_nb_inplace_matrix_multiply HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_tp_finalize HPyFunc_DESTRUCTOR #define _HPySlot_SIG__HPy_tp_destroy HPyFunc_DESTROYFUNC +#define _HPySlot_SIG__HPy_mod_create HPyFunc_MOD_CREATE +#define _HPySlot_SIG__HPy_mod_exec HPyFunc_INQUIRY diff --git a/hpy/devel/include/hpy/cpy_types.h b/hpy/devel/include/hpy/cpy_types.h index f32eda3e1..461a02858 100644 --- a/hpy/devel/include/hpy/cpy_types.h +++ b/hpy/devel/include/hpy/cpy_types.h @@ -19,6 +19,7 @@ typedef struct FORBIDDEN_cpy_PyObject cpy_PyObject; typedef struct FORBIDDEN_PyMethodDef cpy_PyMethodDef; +typedef struct FORBIDDEN_PyModuleDef cpy_PyModuleDef; typedef struct FORBIDDEN_bufferinfo cpy_Py_buffer; // declare the following API functions as _HPY_LEGACY, which triggers an @@ -31,6 +32,7 @@ HPyAPI_FUNC _HPY_LEGACY HPy HPy_FromPyObject(HPyContext *ctx, cpy_PyObject *obj) // Python.h has already been included by the main hpy.h typedef PyObject cpy_PyObject; typedef PyMethodDef cpy_PyMethodDef; +typedef PyModuleDef cpy_PyModuleDef; typedef Py_buffer cpy_Py_buffer; #endif /* HPY_ABI_UNIVERSAL */ diff --git a/hpy/devel/include/hpy/cpython/hpyfunc_trampolines.h b/hpy/devel/include/hpy/cpython/hpyfunc_trampolines.h index ec03269cd..926811882 100644 --- a/hpy/devel/include/hpy/cpython/hpyfunc_trampolines.h +++ b/hpy/devel/include/hpy/cpython/hpyfunc_trampolines.h @@ -111,4 +111,16 @@ typedef int (*_HPyCFunction_RELEASEBUFFERPROC)(HPyContext *, HPy, HPy_buffer *); PyCapsule_GetContext(capsule)); \ } +extern void +_HPyModule_CheckCreateSlotResult(cpy_PyObject **result); + +#define _HPyFunc_TRAMPOLINE_HPyFunc_MOD_CREATE(SYM, IMPL) \ + static cpy_PyObject* SYM(cpy_PyObject *spec, cpy_PyModuleDef *def) \ + { \ + (void) def; /* avoid 'unused' warning */ \ + cpy_PyObject* result = _h2py(IMPL(_HPyGetContext(), _py2h(spec))); \ + _HPyModule_CheckCreateSlotResult(&result); \ + return result; \ + } + #endif // HPY_CPYTHON_HPYFUNC_TRAMPOLINES_H diff --git a/hpy/devel/include/hpy/hpyfunc.h b/hpy/devel/include/hpy/hpyfunc.h index a639b90c7..654c525ee 100644 --- a/hpy/devel/include/hpy/hpyfunc.h +++ b/hpy/devel/include/hpy/hpyfunc.h @@ -41,6 +41,8 @@ typedef enum { HPyFunc_DESTRUCTOR, HPyFunc_CAPSULE_DESTRUCTOR, + HPyFunc_MOD_CREATE, + } HPyFunc_Signature; /* The typedefs corresponding to the various HPyFunc_Signature members diff --git a/hpy/devel/include/hpy/hpymodule.h b/hpy/devel/include/hpy/hpymodule.h index 27f601603..79e4718a6 100644 --- a/hpy/devel/include/hpy/hpymodule.h +++ b/hpy/devel/include/hpy/hpymodule.h @@ -19,9 +19,18 @@ extern HPyContext *_ctx_for_trampolines; #endif +/** + * Unlike CPython, HPy module definition does not specify module name. + * The name if always taken from the ModuleSpec (PEP 451). + */ typedef struct { - const char* name; const char* doc; + /** + * Size of the module state structure. If set to zero, then the module + * will not get allocated and assigned any HPy module state. Negative + * size, unlike in CPython API, does not have any specific meaning and + * will produce a runtime error. + */ HPy_ssize_t size; cpy_PyMethodDef *legacy_methods; HPyDef **defines; /* points to an array of 'HPyDef *' */ @@ -32,45 +41,50 @@ typedef struct { #if defined(__cplusplus) -# define HPyVERSION_FUNC extern "C" HPy_EXPORTED_SYMBOL uint32_t -# define HPyMODINIT_FUNC extern "C" HPy_EXPORTED_SYMBOL HPy +# define HPy_EXPORTED_FUNC extern "C" HPy_EXPORTED_SYMBOL #else /* __cplusplus */ -# define HPyVERSION_FUNC HPy_EXPORTED_SYMBOL uint32_t -# define HPyMODINIT_FUNC HPy_EXPORTED_SYMBOL HPy +# define HPy_EXPORTED_FUNC HPy_EXPORTED_SYMBOL #endif /* __cplusplus */ #ifdef HPY_ABI_CPYTHON +// helpers provided by HPy runtime: +#include "hpy/runtime/ctx_module.h" + // module initialization in the CPython case -#define HPy_MODINIT(modname) \ - static HPy init_##modname##_impl(HPyContext *ctx); \ - PyMODINIT_FUNC \ - PyInit_##modname(void) \ - { \ - return _h2py(init_##modname##_impl(_HPyGetContext())); \ +#define HPy_MODINIT(ext_name, mod_def) \ + PyMODINIT_FUNC \ + PyInit_##ext_name(void) \ + { \ + return _HPyModuleDef_AsPyInit(&mod_def); \ } #else // HPY_ABI_CPYTHON // module initialization in the universal and hybrid case -#define HPy_MODINIT(modname) \ - HPyVERSION_FUNC \ - get_required_hpy_major_version_##modname() \ - { \ - return HPY_ABI_VERSION; \ - } \ - HPyVERSION_FUNC \ - get_required_hpy_minor_version_##modname() \ - { \ - return HPY_ABI_VERSION_MINOR; \ - } \ - _HPy_CTX_MODIFIER HPyContext *_ctx_for_trampolines; \ - static HPy init_##modname##_impl(HPyContext *ctx); \ - HPyMODINIT_FUNC \ - HPyInit_##modname(HPyContext *ctx) \ - { \ - _ctx_for_trampolines = ctx; \ - return init_##modname##_impl(ctx); \ +// the global HPyContext is used by the CPython trampolines +// generated by the HPyDef_XXX macros +#define HPy_MODINIT(ext_name, mod_def) \ + HPy_EXPORTED_FUNC uint32_t \ + get_required_hpy_major_version_##ext_name() \ + { \ + return HPY_ABI_VERSION; \ + } \ + HPy_EXPORTED_FUNC uint32_t \ + get_required_hpy_minor_version_##ext_name() \ + { \ + return HPY_ABI_VERSION_MINOR; \ + } \ + _HPy_CTX_MODIFIER HPyContext *_ctx_for_trampolines; \ + HPy_EXPORTED_FUNC void \ + HPyInitGlobalContext_##ext_name(HPyContext *ctx) \ + { \ + _ctx_for_trampolines = ctx; \ + } \ + HPy_EXPORTED_FUNC HPyModuleDef* \ + HPyInit_##ext_name() \ + { \ + return &mod_def; \ } #endif // HPY_ABI_CPYTHON diff --git a/hpy/devel/include/hpy/runtime/ctx_module.h b/hpy/devel/include/hpy/runtime/ctx_module.h new file mode 100644 index 000000000..8cb6549cc --- /dev/null +++ b/hpy/devel/include/hpy/runtime/ctx_module.h @@ -0,0 +1,25 @@ +#ifndef HPY_COMMON_RUNTIME_CTX_MODULE_H +#define HPY_COMMON_RUNTIME_CTX_MODULE_H + +#include +#include "hpy.h" + +// Helper functions for CPython implementation (both CPython ABI and +// HPy universal module impl for CPython) + +/** Converts HPy module definition to CPython module definition for multiphase + * initialization */ +_HPy_HIDDEN PyModuleDef* +_HPyModuleDef_CreatePyModuleDef(HPyModuleDef *hpydef); + +/** Converts HPy module definition to PyObject that wraps CPython module + * definition for multiphase initialization */ +_HPy_HIDDEN PyObject* +_HPyModuleDef_AsPyInit(HPyModuleDef *hpydef); + +/** Implements the extra HPy specific validation that should be applied to the + * result of the HPy_mod_create slot. */ +_HPy_HIDDEN void +_HPyModule_CheckCreateSlotResult(PyObject **result); + +#endif //HPY_COMMON_RUNTIME_CTX_MODULE_H diff --git a/hpy/devel/include/hpy/universal/autogen_ctx.h b/hpy/devel/include/hpy/universal/autogen_ctx.h index 162cbca16..b980f6885 100644 --- a/hpy/devel/include/hpy/universal/autogen_ctx.h +++ b/hpy/devel/include/hpy/universal/autogen_ctx.h @@ -91,7 +91,6 @@ struct _HPyContext_s { HPy h_UnicodeType; HPy h_TupleType; HPy h_ListType; - HPy (*ctx_Module_Create)(HPyContext *ctx, HPyModuleDef *def); HPy (*ctx_Dup)(HPyContext *ctx, HPy h); void (*ctx_Close)(HPyContext *ctx, HPy h); HPy (*ctx_Long_FromLong)(HPyContext *ctx, long value); diff --git a/hpy/devel/include/hpy/universal/autogen_trampolines.h b/hpy/devel/include/hpy/universal/autogen_trampolines.h index 4defc7912..60eea9498 100644 --- a/hpy/devel/include/hpy/universal/autogen_trampolines.h +++ b/hpy/devel/include/hpy/universal/autogen_trampolines.h @@ -10,10 +10,6 @@ */ -HPyAPI_FUNC HPy HPyModule_Create(HPyContext *ctx, HPyModuleDef *def) { - return ctx->ctx_Module_Create ( ctx, def ); -} - HPyAPI_FUNC HPy HPy_Dup(HPyContext *ctx, HPy h) { return ctx->ctx_Dup ( ctx, h ); } diff --git a/hpy/devel/include/hpy/universal/hpyfunc_trampolines.h b/hpy/devel/include/hpy/universal/hpyfunc_trampolines.h index daf80fd67..18a35da62 100644 --- a/hpy/devel/include/hpy/universal/hpyfunc_trampolines.h +++ b/hpy/devel/include/hpy/universal/hpyfunc_trampolines.h @@ -168,5 +168,20 @@ typedef struct { HPyFunc_CAPSULE_DESTRUCTOR, (HPyCFunction)IMPL, capsule); \ } +typedef struct { + cpy_PyObject *spec; + cpy_PyObject *result; +} _HPyFunc_args_MOD_CREATE; + +#define _HPyFunc_TRAMPOLINE_HPyFunc_MOD_CREATE(SYM, IMPL) \ + static cpy_PyObject* SYM(cpy_PyObject *spec, cpy_PyModuleDef *def) \ + { \ + (void) def; /* avoid 'unused' warning */ \ + _HPyFunc_args_UNARYFUNC a = { spec }; \ + _HPy_CallRealFunctionFromTrampoline( \ + _ctx_for_trampolines, HPyFunc_MOD_CREATE, (HPyCFunction)IMPL, &a); \ + return a.result; \ + } + #endif // HPY_UNIVERSAL_HPYFUNC_TRAMPOLINES_H diff --git a/hpy/devel/src/runtime/ctx_module.c b/hpy/devel/src/runtime/ctx_module.c index 209e23e83..8d318c03e 100644 --- a/hpy/devel/src/runtime/ctx_module.c +++ b/hpy/devel/src/runtime/ctx_module.c @@ -7,32 +7,146 @@ # include "handles.h" #endif +#define NON_DEFAULT_MESSAGE \ + "This is not allowed because custom " \ + "HPy_mod_create slot cannot return a builtin module " \ + "object and cannot make any use of any other data " \ + "defined in the HPyModuleDef. Either do not define " \ + "HPy_mod_create slot and let the runtime create a builtin " \ + "module object from the provided HPyModuleDef, or do not define " \ + "anything else but the HPy_mod_create slot." + static PyModuleDef empty_moduledef = { PyModuleDef_HEAD_INIT }; -_HPy_HIDDEN HPy -ctx_Module_Create(HPyContext *ctx, HPyModuleDef *hpydef) +static PyModuleDef_Slot* create_mod_slots(HPyModuleDef *hpydef, bool *found_create) { - // create a new PyModuleDef + size_t slots_count = 0; + bool found_non_create = false; + for (int i = 0; hpydef->defines[i] != NULL; i++) { + HPyDef *src = hpydef->defines[i]; + if (src->kind != HPyDef_Kind_Slot) { + found_non_create = true; + continue; + } + slots_count++; + if (src->slot.slot == HPy_mod_create) { + if (*found_create) { + PyErr_SetString(PyExc_SystemError, "Multiple definitions " + "of the HPy_mod_create " + "slot in HPyModuleDef.defines."); + return NULL; + } + *found_create = true; + } else if (src->slot.slot != HPy_mod_exec) { + PyErr_Format(PyExc_SystemError, "Unsupported slot in " + "HPyModuleDef.defines (value: %d).", + (int) src->slot.slot); + return NULL; + } else { + assert(src->slot.slot == HPy_mod_exec); + found_non_create = true; + } + } + if (*found_create && found_non_create) { + PyErr_Format(PyExc_SystemError, + "HPyModuleDef defines a HPy_mod_create slot and some other " + "slots or methods. " NON_DEFAULT_MESSAGE); + return NULL; + } + + PyModuleDef_Slot* m_slots = (PyModuleDef_Slot*)PyMem_Calloc( + slots_count + 1, sizeof(PyModuleDef_Slot)); + m_slots[slots_count].slot = 0; + m_slots[slots_count].value = NULL; + size_t slot_index = 0; + for (int i = 0; hpydef->defines[i] != NULL; i++) { + HPyDef *src = hpydef->defines[i]; + if (src->kind != HPyDef_Kind_Slot) + continue; + int py_slot; + if (src->slot.slot == HPy_mod_create) { + py_slot = Py_mod_create; + } else { + assert(src->slot.slot == HPy_mod_exec); + py_slot = Py_mod_exec; + } + m_slots[slot_index].slot = py_slot; + m_slots[slot_index].value = (void*) src->slot.cpy_trampoline; + slot_index++; + } + return m_slots; +} - // we can't free this memory because it is stitched into moduleobject. We - // just make it immortal for now, eventually we should think whether or - // not to free it if/when we unload the module +_HPy_HIDDEN PyModuleDef* +_HPyModuleDef_CreatePyModuleDef(HPyModuleDef *hpydef) +{ PyModuleDef *def = (PyModuleDef*)PyMem_Malloc(sizeof(PyModuleDef)); if (def == NULL) { PyErr_NoMemory(); - return HPy_NULL; + return NULL; } memcpy(def, &empty_moduledef, sizeof(PyModuleDef)); - def->m_name = hpydef->name; def->m_doc = hpydef->doc; - def->m_size = hpydef->size; + if (hpydef->size < 0) { + PyErr_SetString(PyExc_SystemError, "HPy does not permit " + "HPyModuleDef.size < 0"); + goto error; + } else if (hpydef->size > 0) { + // GH-328 + PyErr_SetString(PyExc_SystemError, "Module state is not supported yet " + "in HPy, set HPyModuleDef.size = 0 " + "if module state is not needed"); + goto error; + } + def->m_methods = create_method_defs(hpydef->defines, hpydef->legacy_methods); if (def->m_methods == NULL) { + goto error; + } + + if (hpydef->defines != NULL) { + bool found_create = false; + def->m_slots = create_mod_slots(hpydef, &found_create); + if (def->m_slots == NULL) { + goto error; + } + if (found_create && (hpydef->legacy_methods || hpydef->size > 0 || + hpydef->doc != NULL || hpydef->globals != NULL)) { + PyErr_Format(PyExc_SystemError, + "HPyModuleDef defines a HPy_mod_create slot and some " + "of the other fields are not set to their default " + "value. " NON_DEFAULT_MESSAGE); + goto error; + } + } + + return def; +error: + if (def != NULL) { PyMem_Free(def); - return HPy_NULL; } - PyObject *result = PyModule_Create(def); - return _py2h(result); + return NULL; +} + +_HPy_HIDDEN PyObject* +_HPyModuleDef_AsPyInit(HPyModuleDef *hpydef) +{ + PyModuleDef *def = _HPyModuleDef_CreatePyModuleDef(hpydef); + if (def == NULL) { + return NULL; + } + return PyModuleDef_Init(def); +} + +_HPy_HIDDEN void +_HPyModule_CheckCreateSlotResult(PyObject **result) +{ + if (*result != NULL && PyModule_Check(*result)) { + PyErr_SetString(PyExc_SystemError, + "HPy_mod_create slot returned a builtin module object. " + "This is currently not supported."); + *result = NULL; + } } diff --git a/hpy/tools/autogen/hpyfunc.py b/hpy/tools/autogen/hpyfunc.py index 64fbe943e..6089d47e9 100644 --- a/hpy/tools/autogen/hpyfunc.py +++ b/hpy/tools/autogen/hpyfunc.py @@ -4,7 +4,7 @@ from .parse import toC, find_typedecl NO_CALL = ('NOARGS', 'O', 'VARARGS', 'KEYWORDS', 'INITPROC', 'DESTROYFUNC', - 'GETBUFFERPROC', 'RELEASEBUFFERPROC', 'TRAVERSEPROC') + 'GETBUFFERPROC', 'RELEASEBUFFERPROC', 'TRAVERSEPROC', 'MOD_CREATE') NO_TRAMPOLINE = NO_CALL + ('RICHCMPFUNC',) class autogen_hpyfunc_declare_h(AutoGenFile): @@ -20,6 +20,8 @@ def generate(self): # declare a function named 'SYM' of the appropriate type funcdecl = hpyfunc.node.type.type symdecl = deepcopy(funcdecl) + if isinstance(symdecl.type, c_ast.PtrDecl): + symdecl.type = symdecl.type.type symdecl.type.declname = 'SYM' symdecl = toC(symdecl) # @@ -55,9 +57,11 @@ def generate(self): continue # tramp_node = deepcopy(hpyfunc.node.type.type) + if isinstance(tramp_node.type, c_ast.PtrDecl): + tramp_node.type = tramp_node.type.type tramp_node.type.declname = 'SYM' tramp_node = hpy_to_cpy(tramp_node) - assert toC(tramp_node.args.params[0].type) == 'HPyContext *' + assert toC(tramp_node.args.params[0].type) in ['void', 'HPyContext *'] tramp_node.args.params = [hpy_to_cpy(p) for p in tramp_node.args.params[1:]] for i, param in enumerate(tramp_node.args.params): @@ -144,6 +148,8 @@ def generate(self): continue # tramp_node = deepcopy(hpyfunc.node.type.type) + if isinstance(tramp_node.type, c_ast.PtrDecl): + tramp_node.type = tramp_node.type.type tramp_node.type.declname = 'SYM' tramp_node = hpy_to_cpy(tramp_node) tramp_node.args.params = [hpy_to_cpy(p) diff --git a/hpy/tools/autogen/public_api.h b/hpy/tools/autogen/public_api.h index ebef8dc1b..ec1bda01c 100644 --- a/hpy/tools/autogen/public_api.h +++ b/hpy/tools/autogen/public_api.h @@ -96,361 +96,359 @@ HPy_ID(73) HPy h_FloatType; /* built-in 'float' */ HPy_ID(74) HPy h_UnicodeType; /* built-in 'str' */ HPy_ID(75) HPy h_TupleType; /* built-in 'tuple' */ HPy_ID(76) HPy h_ListType; /* built-in 'list' */ -HPy_ID(239) HPy h_ComplexType; /* built-in 'complex' */ -HPy_ID(240) HPy h_BytesType; /* built-in 'bytes' */ -HPy_ID(241) HPy h_MemoryViewType; /* built-in 'memoryview' */ -HPy_ID(242) HPy h_CapsuleType; /* built-in 'capsule' */ -HPy_ID(243) HPy h_SliceType; /* built-in 'slice' */ +HPy_ID(238) HPy h_ComplexType; /* built-in 'complex' */ +HPy_ID(239) HPy h_BytesType; /* built-in 'bytes' */ +HPy_ID(240) HPy h_MemoryViewType; /* built-in 'memoryview' */ +HPy_ID(241) HPy h_CapsuleType; /* built-in 'capsule' */ +HPy_ID(242) HPy h_SliceType; /* built-in 'slice' */ /* Reflection */ -HPy_ID(244) HPy h_Builtins; /* dict of builtins */ +HPy_ID(243) HPy h_Builtins; /* dict of builtins */ #endif HPy_ID(77) -HPy HPyModule_Create(HPyContext *ctx, HPyModuleDef *def); -HPy_ID(78) HPy HPy_Dup(HPyContext *ctx, HPy h); -HPy_ID(79) +HPy_ID(78) void HPy_Close(HPyContext *ctx, HPy h); -HPy_ID(80) +HPy_ID(79) HPy HPyLong_FromLong(HPyContext *ctx, long value); -HPy_ID(81) +HPy_ID(80) HPy HPyLong_FromUnsignedLong(HPyContext *ctx, unsigned long value); -HPy_ID(82) +HPy_ID(81) HPy HPyLong_FromLongLong(HPyContext *ctx, long long v); -HPy_ID(83) +HPy_ID(82) HPy HPyLong_FromUnsignedLongLong(HPyContext *ctx, unsigned long long v); -HPy_ID(84) +HPy_ID(83) HPy HPyLong_FromSize_t(HPyContext *ctx, size_t value); -HPy_ID(85) +HPy_ID(84) HPy HPyLong_FromSsize_t(HPyContext *ctx, HPy_ssize_t value); -HPy_ID(86) +HPy_ID(85) long HPyLong_AsLong(HPyContext *ctx, HPy h); -HPy_ID(87) +HPy_ID(86) unsigned long HPyLong_AsUnsignedLong(HPyContext *ctx, HPy h); -HPy_ID(88) +HPy_ID(87) unsigned long HPyLong_AsUnsignedLongMask(HPyContext *ctx, HPy h); -HPy_ID(89) +HPy_ID(88) long long HPyLong_AsLongLong(HPyContext *ctx, HPy h); -HPy_ID(90) +HPy_ID(89) unsigned long long HPyLong_AsUnsignedLongLong(HPyContext *ctx, HPy h); -HPy_ID(91) +HPy_ID(90) unsigned long long HPyLong_AsUnsignedLongLongMask(HPyContext *ctx, HPy h); -HPy_ID(92) +HPy_ID(91) size_t HPyLong_AsSize_t(HPyContext *ctx, HPy h); -HPy_ID(93) +HPy_ID(92) HPy_ssize_t HPyLong_AsSsize_t(HPyContext *ctx, HPy h); -HPy_ID(94) +HPy_ID(93) void* HPyLong_AsVoidPtr(HPyContext *ctx, HPy h); -HPy_ID(95) +HPy_ID(94) double HPyLong_AsDouble(HPyContext *ctx, HPy h); -HPy_ID(96) +HPy_ID(95) HPy HPyFloat_FromDouble(HPyContext *ctx, double v); -HPy_ID(97) +HPy_ID(96) double HPyFloat_AsDouble(HPyContext *ctx, HPy h); -HPy_ID(98) +HPy_ID(97) HPy HPyBool_FromLong(HPyContext *ctx, long v); /* abstract.h */ -HPy_ID(99) +HPy_ID(98) HPy_ssize_t HPy_Length(HPyContext *ctx, HPy h); -HPy_ID(100) +HPy_ID(99) int HPyNumber_Check(HPyContext *ctx, HPy h); -HPy_ID(101) +HPy_ID(100) HPy HPy_Add(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(102) +HPy_ID(101) HPy HPy_Subtract(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(103) +HPy_ID(102) HPy HPy_Multiply(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(104) +HPy_ID(103) HPy HPy_MatrixMultiply(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(105) +HPy_ID(104) HPy HPy_FloorDivide(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(106) +HPy_ID(105) HPy HPy_TrueDivide(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(107) +HPy_ID(106) HPy HPy_Remainder(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(108) +HPy_ID(107) HPy HPy_Divmod(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(109) +HPy_ID(108) HPy HPy_Power(HPyContext *ctx, HPy h1, HPy h2, HPy h3); -HPy_ID(110) +HPy_ID(109) HPy HPy_Negative(HPyContext *ctx, HPy h1); -HPy_ID(111) +HPy_ID(110) HPy HPy_Positive(HPyContext *ctx, HPy h1); -HPy_ID(112) +HPy_ID(111) HPy HPy_Absolute(HPyContext *ctx, HPy h1); -HPy_ID(113) +HPy_ID(112) HPy HPy_Invert(HPyContext *ctx, HPy h1); -HPy_ID(114) +HPy_ID(113) HPy HPy_Lshift(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(115) +HPy_ID(114) HPy HPy_Rshift(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(116) +HPy_ID(115) HPy HPy_And(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(117) +HPy_ID(116) HPy HPy_Xor(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(118) +HPy_ID(117) HPy HPy_Or(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(119) +HPy_ID(118) HPy HPy_Index(HPyContext *ctx, HPy h1); -HPy_ID(120) +HPy_ID(119) HPy HPy_Long(HPyContext *ctx, HPy h1); -HPy_ID(121) +HPy_ID(120) HPy HPy_Float(HPyContext *ctx, HPy h1); -HPy_ID(122) +HPy_ID(121) HPy HPy_InPlaceAdd(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(123) +HPy_ID(122) HPy HPy_InPlaceSubtract(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(124) +HPy_ID(123) HPy HPy_InPlaceMultiply(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(125) +HPy_ID(124) HPy HPy_InPlaceMatrixMultiply(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(126) +HPy_ID(125) HPy HPy_InPlaceFloorDivide(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(127) +HPy_ID(126) HPy HPy_InPlaceTrueDivide(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(128) +HPy_ID(127) HPy HPy_InPlaceRemainder(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(129) +HPy_ID(128) HPy HPy_InPlacePower(HPyContext *ctx, HPy h1, HPy h2, HPy h3); -HPy_ID(130) +HPy_ID(129) HPy HPy_InPlaceLshift(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(131) +HPy_ID(130) HPy HPy_InPlaceRshift(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(132) +HPy_ID(131) HPy HPy_InPlaceAnd(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(133) +HPy_ID(132) HPy HPy_InPlaceXor(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(134) +HPy_ID(133) HPy HPy_InPlaceOr(HPyContext *ctx, HPy h1, HPy h2); -HPy_ID(135) +HPy_ID(134) int HPyCallable_Check(HPyContext *ctx, HPy h); -HPy_ID(136) +HPy_ID(135) HPy HPy_CallTupleDict(HPyContext *ctx, HPy callable, HPy args, HPy kw); /* pyerrors.h */ -HPy_ID(137) +HPy_ID(136) void HPy_FatalError(HPyContext *ctx, const char *message); -HPy_ID(138) +HPy_ID(137) HPy HPyErr_SetString(HPyContext *ctx, HPy h_type, const char *message); -HPy_ID(139) +HPy_ID(138) HPy HPyErr_SetObject(HPyContext *ctx, HPy h_type, HPy h_value); /* note: the filename will be FS decoded */ -HPy_ID(140) +HPy_ID(139) HPy HPyErr_SetFromErrnoWithFilename(HPyContext *ctx, HPy h_type, const char *filename_fsencoded); -HPy_ID(141) +HPy_ID(140) HPy HPyErr_SetFromErrnoWithFilenameObjects(HPyContext *ctx, HPy h_type, HPy filename1, HPy filename2); /* note: HPyErr_Occurred() returns a flag 0-or-1, instead of a 'PyObject *' */ -HPy_ID(142) +HPy_ID(141) int HPyErr_Occurred(HPyContext *ctx); -HPy_ID(143) +HPy_ID(142) int HPyErr_ExceptionMatches(HPyContext *ctx, HPy exc); -HPy_ID(144) +HPy_ID(143) HPy HPyErr_NoMemory(HPyContext *ctx); -HPy_ID(145) +HPy_ID(144) void HPyErr_Clear(HPyContext *ctx); -HPy_ID(146) +HPy_ID(145) HPy HPyErr_NewException(HPyContext *ctx, const char *name, HPy base, HPy dict); -HPy_ID(147) +HPy_ID(146) HPy HPyErr_NewExceptionWithDoc(HPyContext *ctx, const char *name, const char *doc, HPy base, HPy dict); -HPy_ID(148) +HPy_ID(147) int HPyErr_WarnEx(HPyContext *ctx, HPy category, const char *message, HPy_ssize_t stack_level); -HPy_ID(149) +HPy_ID(148) void HPyErr_WriteUnraisable(HPyContext *ctx, HPy obj); /* object.h */ -HPy_ID(150) +HPy_ID(149) int HPy_IsTrue(HPyContext *ctx, HPy h); -HPy_ID(151) +HPy_ID(150) HPy HPyType_FromSpec(HPyContext *ctx, HPyType_Spec *spec, HPyType_SpecParam *params); -HPy_ID(152) +HPy_ID(151) HPy HPyType_GenericNew(HPyContext *ctx, HPy type, HPy *args, HPy_ssize_t nargs, HPy kw); -HPy_ID(153) +HPy_ID(152) HPy HPy_GetAttr(HPyContext *ctx, HPy obj, HPy name); -HPy_ID(154) +HPy_ID(153) HPy HPy_GetAttr_s(HPyContext *ctx, HPy obj, const char *name); -HPy_ID(155) +HPy_ID(154) int HPy_HasAttr(HPyContext *ctx, HPy obj, HPy name); -HPy_ID(156) +HPy_ID(155) int HPy_HasAttr_s(HPyContext *ctx, HPy obj, const char *name); -HPy_ID(157) +HPy_ID(156) int HPy_SetAttr(HPyContext *ctx, HPy obj, HPy name, HPy value); -HPy_ID(158) +HPy_ID(157) int HPy_SetAttr_s(HPyContext *ctx, HPy obj, const char *name, HPy value); -HPy_ID(159) +HPy_ID(158) HPy HPy_GetItem(HPyContext *ctx, HPy obj, HPy key); -HPy_ID(160) +HPy_ID(159) HPy HPy_GetItem_i(HPyContext *ctx, HPy obj, HPy_ssize_t idx); -HPy_ID(161) +HPy_ID(160) HPy HPy_GetItem_s(HPyContext *ctx, HPy obj, const char *key); -HPy_ID(162) +HPy_ID(161) int HPy_Contains(HPyContext *ctx, HPy container, HPy key); -HPy_ID(163) +HPy_ID(162) int HPy_SetItem(HPyContext *ctx, HPy obj, HPy key, HPy value); -HPy_ID(164) +HPy_ID(163) int HPy_SetItem_i(HPyContext *ctx, HPy obj, HPy_ssize_t idx, HPy value); -HPy_ID(165) +HPy_ID(164) int HPy_SetItem_s(HPyContext *ctx, HPy obj, const char *key, HPy value); -HPy_ID(236) +HPy_ID(235) int HPy_DelItem(HPyContext *ctx, HPy obj, HPy key); -HPy_ID(237) +HPy_ID(236) int HPy_DelItem_i(HPyContext *ctx, HPy obj, HPy_ssize_t idx); -HPy_ID(238) +HPy_ID(237) int HPy_DelItem_s(HPyContext *ctx, HPy obj, const char *key); -HPy_ID(166) +HPy_ID(165) HPy HPy_Type(HPyContext *ctx, HPy obj); // WARNING: HPy_TypeCheck could be tweaked/removed in the future, see issue #160 -HPy_ID(167) +HPy_ID(166) int HPy_TypeCheck(HPyContext *ctx, HPy obj, HPy type); -HPy_ID(168) +HPy_ID(167) int HPy_Is(HPyContext *ctx, HPy obj, HPy other); -HPy_ID(169) +HPy_ID(168) void* _HPy_AsStruct_Object(HPyContext *ctx, HPy h); -HPy_ID(170) +HPy_ID(169) void* _HPy_AsStruct_Legacy(HPyContext *ctx, HPy h); -HPy_ID(229) +HPy_ID(228) void* _HPy_AsStruct_Type(HPyContext *ctx, HPy h); -HPy_ID(230) +HPy_ID(229) void* _HPy_AsStruct_Long(HPyContext *ctx, HPy h); -HPy_ID(231) +HPy_ID(230) void* _HPy_AsStruct_Float(HPyContext *ctx, HPy h); -HPy_ID(232) +HPy_ID(231) void* _HPy_AsStruct_Unicode(HPyContext *ctx, HPy h); -HPy_ID(233) +HPy_ID(232) void* _HPy_AsStruct_Tuple(HPyContext *ctx, HPy h); -HPy_ID(234) +HPy_ID(233) void* _HPy_AsStruct_List(HPyContext *ctx, HPy h); -HPy_ID(235) +HPy_ID(234) HPyType_BuiltinShape _HPyType_GetBuiltinShape(HPyContext *ctx, HPy h_type); -HPy_ID(171) +HPy_ID(170) HPy _HPy_New(HPyContext *ctx, HPy h_type, void **data); -HPy_ID(172) +HPy_ID(171) HPy HPy_Repr(HPyContext *ctx, HPy obj); -HPy_ID(173) +HPy_ID(172) HPy HPy_Str(HPyContext *ctx, HPy obj); -HPy_ID(174) +HPy_ID(173) HPy HPy_ASCII(HPyContext *ctx, HPy obj); -HPy_ID(175) +HPy_ID(174) HPy HPy_Bytes(HPyContext *ctx, HPy obj); -HPy_ID(176) +HPy_ID(175) HPy HPy_RichCompare(HPyContext *ctx, HPy v, HPy w, int op); -HPy_ID(177) +HPy_ID(176) int HPy_RichCompareBool(HPyContext *ctx, HPy v, HPy w, int op); -HPy_ID(178) +HPy_ID(177) HPy_hash_t HPy_Hash(HPyContext *ctx, HPy obj); /* bytesobject.h */ -HPy_ID(179) +HPy_ID(178) int HPyBytes_Check(HPyContext *ctx, HPy h); -HPy_ID(180) +HPy_ID(179) HPy_ssize_t HPyBytes_Size(HPyContext *ctx, HPy h); -HPy_ID(181) +HPy_ID(180) HPy_ssize_t HPyBytes_GET_SIZE(HPyContext *ctx, HPy h); -HPy_ID(182) +HPy_ID(181) const char* HPyBytes_AsString(HPyContext *ctx, HPy h); -HPy_ID(183) +HPy_ID(182) const char* HPyBytes_AS_STRING(HPyContext *ctx, HPy h); -HPy_ID(184) +HPy_ID(183) HPy HPyBytes_FromString(HPyContext *ctx, const char *v); -HPy_ID(185) +HPy_ID(184) HPy HPyBytes_FromStringAndSize(HPyContext *ctx, const char *v, HPy_ssize_t len); /* unicodeobject.h */ -HPy_ID(186) +HPy_ID(185) HPy HPyUnicode_FromString(HPyContext *ctx, const char *utf8); -HPy_ID(187) +HPy_ID(186) int HPyUnicode_Check(HPyContext *ctx, HPy h); -HPy_ID(188) +HPy_ID(187) HPy HPyUnicode_AsASCIIString(HPyContext *ctx, HPy h); -HPy_ID(189) +HPy_ID(188) HPy HPyUnicode_AsLatin1String(HPyContext *ctx, HPy h); -HPy_ID(190) +HPy_ID(189) HPy HPyUnicode_AsUTF8String(HPyContext *ctx, HPy h); -HPy_ID(191) +HPy_ID(190) const char* HPyUnicode_AsUTF8AndSize(HPyContext *ctx, HPy h, HPy_ssize_t *size); -HPy_ID(192) +HPy_ID(191) HPy HPyUnicode_FromWideChar(HPyContext *ctx, const wchar_t *w, HPy_ssize_t size); -HPy_ID(193) +HPy_ID(192) HPy HPyUnicode_DecodeFSDefault(HPyContext *ctx, const char* v); -HPy_ID(194) +HPy_ID(193) HPy HPyUnicode_DecodeFSDefaultAndSize(HPyContext *ctx, const char* v, HPy_ssize_t size); -HPy_ID(195) +HPy_ID(194) HPy HPyUnicode_EncodeFSDefault(HPyContext *ctx, HPy h); -HPy_ID(196) +HPy_ID(195) HPy_UCS4 HPyUnicode_ReadChar(HPyContext *ctx, HPy h, HPy_ssize_t index); -HPy_ID(197) +HPy_ID(196) HPy HPyUnicode_DecodeASCII(HPyContext *ctx, const char *s, HPy_ssize_t size, const char *errors); -HPy_ID(198) +HPy_ID(197) HPy HPyUnicode_DecodeLatin1(HPyContext *ctx, const char *s, HPy_ssize_t size, const char *errors); /* listobject.h */ -HPy_ID(199) +HPy_ID(198) int HPyList_Check(HPyContext *ctx, HPy h); -HPy_ID(200) +HPy_ID(199) HPy HPyList_New(HPyContext *ctx, HPy_ssize_t len); -HPy_ID(201) +HPy_ID(200) int HPyList_Append(HPyContext *ctx, HPy h_list, HPy h_item); /* dictobject.h */ -HPy_ID(202) +HPy_ID(201) int HPyDict_Check(HPyContext *ctx, HPy h); -HPy_ID(203) +HPy_ID(202) HPy HPyDict_New(HPyContext *ctx); /* tupleobject.h */ -HPy_ID(204) +HPy_ID(203) int HPyTuple_Check(HPyContext *ctx, HPy h); -HPy_ID(205) +HPy_ID(204) HPy HPyTuple_FromArray(HPyContext *ctx, HPy items[], HPy_ssize_t n); // note: HPyTuple_Pack is implemented as a macro in common/macros.h /* import.h */ -HPy_ID(206) +HPy_ID(205) HPy HPyImport_ImportModule(HPyContext *ctx, const char *name); /* pycapsule.h */ -HPy_ID(245) +HPy_ID(244) HPy HPyCapsule_New(HPyContext *ctx, void *pointer, const char *name, HPyCapsule_Destructor *destructor); -HPy_ID(246) +HPy_ID(245) void* HPyCapsule_Get(HPyContext *ctx, HPy capsule, _HPyCapsule_key key, const char *name); -HPy_ID(247) +HPy_ID(246) int HPyCapsule_IsValid(HPyContext *ctx, HPy capsule, const char *name); -HPy_ID(248) +HPy_ID(247) int HPyCapsule_Set(HPyContext *ctx, HPy capsule, _HPyCapsule_key key, void *value); /* integration with the old CPython API */ -HPy_ID(207) +HPy_ID(206) HPy HPy_FromPyObject(HPyContext *ctx, cpy_PyObject *obj); -HPy_ID(208) +HPy_ID(207) cpy_PyObject *HPy_AsPyObject(HPyContext *ctx, HPy h); /* internal helpers which need to be exposed to modules for practical reasons :( */ -HPy_ID(209) +HPy_ID(208) void _HPy_CallRealFunctionFromTrampoline(HPyContext *ctx, HPyFunc_Signature sig, HPyCFunction func, @@ -458,35 +456,35 @@ void _HPy_CallRealFunctionFromTrampoline(HPyContext *ctx, /* Builders */ -HPy_ID(210) +HPy_ID(209) HPyListBuilder HPyListBuilder_New(HPyContext *ctx, HPy_ssize_t initial_size); -HPy_ID(211) +HPy_ID(210) void HPyListBuilder_Set(HPyContext *ctx, HPyListBuilder builder, HPy_ssize_t index, HPy h_item); -HPy_ID(212) +HPy_ID(211) HPy HPyListBuilder_Build(HPyContext *ctx, HPyListBuilder builder); -HPy_ID(213) +HPy_ID(212) void HPyListBuilder_Cancel(HPyContext *ctx, HPyListBuilder builder); -HPy_ID(214) +HPy_ID(213) HPyTupleBuilder HPyTupleBuilder_New(HPyContext *ctx, HPy_ssize_t initial_size); -HPy_ID(215) +HPy_ID(214) void HPyTupleBuilder_Set(HPyContext *ctx, HPyTupleBuilder builder, HPy_ssize_t index, HPy h_item); -HPy_ID(216) +HPy_ID(215) HPy HPyTupleBuilder_Build(HPyContext *ctx, HPyTupleBuilder builder); -HPy_ID(217) +HPy_ID(216) void HPyTupleBuilder_Cancel(HPyContext *ctx, HPyTupleBuilder builder); /* Helper for correctly closing handles */ -HPy_ID(218) +HPy_ID(217) HPyTracker HPyTracker_New(HPyContext *ctx, HPy_ssize_t size); -HPy_ID(219) +HPy_ID(218) int HPyTracker_Add(HPyContext *ctx, HPyTracker ht, HPy h); -HPy_ID(220) +HPy_ID(219) void HPyTracker_ForgetAll(HPyContext *ctx, HPyTracker ht); -HPy_ID(221) +HPy_ID(220) void HPyTracker_Close(HPyContext *ctx, HPyTracker ht); /** @@ -521,9 +519,9 @@ void HPyTracker_Close(HPyContext *ctx, HPyTracker ht); * needs to add write and/or read barriers on the objects. They are ignored by * CPython but e.g. PyPy needs a write barrier. */ -HPy_ID(222) +HPy_ID(221) void HPyField_Store(HPyContext *ctx, HPy target_object, HPyField *target_field, HPy h); -HPy_ID(223) +HPy_ID(222) HPy HPyField_Load(HPyContext *ctx, HPy source_object, HPyField source_field); /** @@ -548,9 +546,9 @@ HPy HPyField_Load(HPyContext *ctx, HPy source_object, HPyField source_field); * HPy_BEGIN_LEAVE_PYTHON/HPy_END_LEAVE_PYTHON becomes equivalent to * Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS. */ -HPy_ID(224) +HPy_ID(223) void HPy_ReenterPythonExecution(HPyContext *ctx, HPyThreadState state); -HPy_ID(225) +HPy_ID(224) HPyThreadState HPy_LeavePythonExecution(HPyContext *ctx); /** @@ -607,13 +605,13 @@ HPyThreadState HPy_LeavePythonExecution(HPyContext *ctx); * also be activated only by some runtime option, letting the HPy implementation * use more optimized HPyGlobal implementation otherwise. */ -HPy_ID(226) +HPy_ID(225) void HPyGlobal_Store(HPyContext *ctx, HPyGlobal *global, HPy h); -HPy_ID(227) +HPy_ID(226) HPy HPyGlobal_Load(HPyContext *ctx, HPyGlobal global); /* Debugging helpers */ -HPy_ID(228) +HPy_ID(227) void _HPy_Dump(HPyContext *ctx, HPy h); @@ -664,6 +662,8 @@ typedef void (*HPyFunc_destructor)(HPyContext *ctx, HPy); typedef void (*HPyFunc_destroyfunc)(void *); +/** Separate type, because we need a different trampoline */ +typedef HPy (*HPyFunc_mod_create)(HPyContext *ctx, HPy); /* ~~~ HPySlot_Slot ~~~ @@ -764,4 +764,20 @@ typedef enum { /* extra HPy slots */ HPy_tp_destroy = SLOT(1000, HPyFunc_DESTROYFUNC), + /** + * Module create slot: the function receives loader spec and should + * return an HPy handle representing the module. Currently, creating + * real module objects cannot be done by user code, so the only other + * useful thing that this slot can do is to create another object that + * can work as a module, such as SimpleNamespace. + */ + HPy_mod_create = SLOT(2000, HPyFunc_MOD_CREATE), + /** + * Module exec slot: the function receives module object that was created + * by the runtime from HPyModuleDef. This slot can do any initialization + * of the module, such as adding types. There can be multiple exec slots + * and they will be executed in the declaration order. + */ + HPy_mod_exec = SLOT(2001, HPyFunc_INQUIRY), + } HPySlot_Slot; diff --git a/hpy/trace/src/_tracemod.c b/hpy/trace/src/_tracemod.c index f4a5f8748..e8bbb207e 100644 --- a/hpy/trace/src/_tracemod.c +++ b/hpy/trace/src/_tracemod.c @@ -199,15 +199,9 @@ static HPyDef *module_defines[] = { }; static HPyModuleDef moduledef = { - .name = "hpy.trace._trace", .doc = "HPy trace mode", - .size = -1, + .size = 0, .defines = module_defines }; - -HPy_MODINIT(_trace) -static HPy init__trace_impl(HPyContext *uctx) -{ - return HPyModule_Create(uctx, &moduledef); -} +HPy_MODINIT(_trace, moduledef) diff --git a/hpy/trace/src/autogen_trace_ctx_init.h b/hpy/trace/src/autogen_trace_ctx_init.h index fe5317545..d392229fd 100644 --- a/hpy/trace/src/autogen_trace_ctx_init.h +++ b/hpy/trace/src/autogen_trace_ctx_init.h @@ -10,7 +10,6 @@ */ -HPy trace_ctx_Module_Create(HPyContext *tctx, HPyModuleDef *def); HPy trace_ctx_Dup(HPyContext *tctx, HPy h); void trace_ctx_Close(HPyContext *tctx, HPy h); HPy trace_ctx_Long_FromLong(HPyContext *tctx, long value); @@ -179,8 +178,8 @@ static inline void trace_ctx_init_info(HPyTraceInfo *info, HPyContext *uctx) { info->magic_number = HPY_TRACE_MAGIC; info->uctx = uctx; - info->call_counts = (uint64_t *)calloc(249, sizeof(uint64_t)); - info->durations = (_HPyTime_t *)calloc(249, sizeof(_HPyTime_t)); + info->call_counts = (uint64_t *)calloc(248, sizeof(uint64_t)); + info->durations = (_HPyTime_t *)calloc(248, sizeof(_HPyTime_t)); info->on_enter_func = HPy_NULL; info->on_exit_func = HPy_NULL; } @@ -279,7 +278,6 @@ static inline void trace_ctx_init_fields(HPyContext *tctx, HPyContext *uctx) tctx->h_CapsuleType = uctx->h_CapsuleType; tctx->h_SliceType = uctx->h_SliceType; tctx->h_Builtins = uctx->h_Builtins; - tctx->ctx_Module_Create = &trace_ctx_Module_Create; tctx->ctx_Dup = &trace_ctx_Dup; tctx->ctx_Close = &trace_ctx_Close; tctx->ctx_Long_FromLong = &trace_ctx_Long_FromLong; diff --git a/hpy/trace/src/autogen_trace_func_table.c b/hpy/trace/src/autogen_trace_func_table.c index 69d3eafee..cd8ee1338 100644 --- a/hpy/trace/src/autogen_trace_func_table.c +++ b/hpy/trace/src/autogen_trace_func_table.c @@ -12,7 +12,7 @@ #include "trace_internal.h" -#define TRACE_NFUNC 166 +#define TRACE_NFUNC 165 #define NO_FUNC "" static const char *trace_func_table[] = { @@ -93,7 +93,6 @@ static const char *trace_func_table[] = { NO_FUNC, NO_FUNC, NO_FUNC, - "ctx_Module_Create", "ctx_Dup", "ctx_Close", "ctx_Long_FromLong", @@ -275,7 +274,7 @@ int hpy_trace_get_nfunc(void) const char * hpy_trace_get_func_name(int idx) { - if (idx >= 0 && idx < 249) + if (idx >= 0 && idx < 248) return trace_func_table[idx]; return NULL; } diff --git a/hpy/trace/src/autogen_trace_wrappers.c b/hpy/trace/src/autogen_trace_wrappers.c index 8e8250934..c4770f9a5 100644 --- a/hpy/trace/src/autogen_trace_wrappers.c +++ b/hpy/trace/src/autogen_trace_wrappers.c @@ -12,2118 +12,2105 @@ #include "trace_internal.h" -HPy trace_ctx_Module_Create(HPyContext *tctx, HPyModuleDef *def) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 77); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyModule_Create(uctx, def); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 77, r0, r1, &_ts_start, &_ts_end); - return res; -} - HPy trace_ctx_Dup(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 78); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 77); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Dup(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 78, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 77, r0, r1, &_ts_start, &_ts_end); return res; } void trace_ctx_Close(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 79); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 78); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy_Close(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 79, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 78, r0, r1, &_ts_start, &_ts_end); } HPy trace_ctx_Long_FromLong(HPyContext *tctx, long value) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 80); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 79); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyLong_FromLong(uctx, value); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 80, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 79, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Long_FromUnsignedLong(HPyContext *tctx, unsigned long value) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 81); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 80); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyLong_FromUnsignedLong(uctx, value); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 81, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 80, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Long_FromLongLong(HPyContext *tctx, long long v) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 82); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 81); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyLong_FromLongLong(uctx, v); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 82, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 81, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Long_FromUnsignedLongLong(HPyContext *tctx, unsigned long long v) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 83); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 82); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyLong_FromUnsignedLongLong(uctx, v); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 83, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 82, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Long_FromSize_t(HPyContext *tctx, size_t value) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 84); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 83); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyLong_FromSize_t(uctx, value); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 84, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 83, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Long_FromSsize_t(HPyContext *tctx, HPy_ssize_t value) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 85); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 84); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyLong_FromSsize_t(uctx, value); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 85, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 84, r0, r1, &_ts_start, &_ts_end); return res; } long trace_ctx_Long_AsLong(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 86); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 85); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); long res = HPyLong_AsLong(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 86, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 85, r0, r1, &_ts_start, &_ts_end); return res; } unsigned long trace_ctx_Long_AsUnsignedLong(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 87); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 86); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); unsigned long res = HPyLong_AsUnsignedLong(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 87, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 86, r0, r1, &_ts_start, &_ts_end); return res; } unsigned long trace_ctx_Long_AsUnsignedLongMask(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 88); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 87); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); unsigned long res = HPyLong_AsUnsignedLongMask(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 88, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 87, r0, r1, &_ts_start, &_ts_end); return res; } long long trace_ctx_Long_AsLongLong(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 89); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 88); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); long long res = HPyLong_AsLongLong(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 89, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 88, r0, r1, &_ts_start, &_ts_end); return res; } unsigned long long trace_ctx_Long_AsUnsignedLongLong(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 90); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 89); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); unsigned long long res = HPyLong_AsUnsignedLongLong(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 90, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 89, r0, r1, &_ts_start, &_ts_end); return res; } unsigned long long trace_ctx_Long_AsUnsignedLongLongMask(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 91); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 90); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); unsigned long long res = HPyLong_AsUnsignedLongLongMask(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 91, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 90, r0, r1, &_ts_start, &_ts_end); return res; } size_t trace_ctx_Long_AsSize_t(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 92); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 91); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); size_t res = HPyLong_AsSize_t(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 92, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 91, r0, r1, &_ts_start, &_ts_end); return res; } HPy_ssize_t trace_ctx_Long_AsSsize_t(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 93); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 92); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy_ssize_t res = HPyLong_AsSsize_t(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 93, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 92, r0, r1, &_ts_start, &_ts_end); return res; } void *trace_ctx_Long_AsVoidPtr(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 94); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 93); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); void * res = HPyLong_AsVoidPtr(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 94, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 93, r0, r1, &_ts_start, &_ts_end); return res; } double trace_ctx_Long_AsDouble(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 95); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 94); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); double res = HPyLong_AsDouble(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 95, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 94, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Float_FromDouble(HPyContext *tctx, double v) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 96); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 95); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyFloat_FromDouble(uctx, v); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 96, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 95, r0, r1, &_ts_start, &_ts_end); return res; } double trace_ctx_Float_AsDouble(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 97); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 96); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); double res = HPyFloat_AsDouble(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 97, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 96, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Bool_FromLong(HPyContext *tctx, long v) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 98); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 97); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyBool_FromLong(uctx, v); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 98, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 97, r0, r1, &_ts_start, &_ts_end); return res; } HPy_ssize_t trace_ctx_Length(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 99); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 98); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy_ssize_t res = HPy_Length(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 99, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 98, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_Number_Check(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 100); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 99); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPyNumber_Check(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 100, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 99, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Add(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 101); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 100); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Add(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 101, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 100, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Subtract(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 102); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 101); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Subtract(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 102, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 101, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Multiply(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 103); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 102); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Multiply(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 103, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 102, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_MatrixMultiply(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 104); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 103); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_MatrixMultiply(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 104, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 103, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_FloorDivide(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 105); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 104); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_FloorDivide(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 105, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 104, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_TrueDivide(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 106); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 105); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_TrueDivide(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 106, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 105, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Remainder(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 107); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 106); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Remainder(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 107, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 106, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Divmod(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 108); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 107); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Divmod(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 108, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 107, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Power(HPyContext *tctx, HPy h1, HPy h2, HPy h3) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 109); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 108); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Power(uctx, h1, h2, h3); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 109, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 108, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Negative(HPyContext *tctx, HPy h1) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 110); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 109); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Negative(uctx, h1); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 110, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 109, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Positive(HPyContext *tctx, HPy h1) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 111); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 110); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Positive(uctx, h1); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 111, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 110, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Absolute(HPyContext *tctx, HPy h1) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 112); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 111); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Absolute(uctx, h1); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 112, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 111, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Invert(HPyContext *tctx, HPy h1) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 113); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 112); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Invert(uctx, h1); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 113, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 112, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Lshift(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 114); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 113); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Lshift(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 114, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 113, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Rshift(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 115); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 114); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Rshift(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 115, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 114, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_And(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 116); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 115); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_And(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 116, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 115, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Xor(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 117); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 116); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Xor(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 117, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 116, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Or(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 118); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 117); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Or(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 118, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 117, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Index(HPyContext *tctx, HPy h1) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 119); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 118); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Index(uctx, h1); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 119, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 118, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Long(HPyContext *tctx, HPy h1) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 120); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 119); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Long(uctx, h1); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 120, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 119, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Float(HPyContext *tctx, HPy h1) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 121); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 120); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Float(uctx, h1); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 121, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 120, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_InPlaceAdd(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 122); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 121); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_InPlaceAdd(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 122, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 121, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_InPlaceSubtract(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 123); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 122); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_InPlaceSubtract(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 123, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 122, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_InPlaceMultiply(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 124); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 123); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_InPlaceMultiply(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 124, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 123, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_InPlaceMatrixMultiply(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 125); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 124); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_InPlaceMatrixMultiply(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 125, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 124, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_InPlaceFloorDivide(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 126); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 125); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_InPlaceFloorDivide(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 126, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 125, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_InPlaceTrueDivide(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 127); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 126); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_InPlaceTrueDivide(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 127, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 126, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_InPlaceRemainder(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 128); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 127); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_InPlaceRemainder(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 128, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 127, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_InPlacePower(HPyContext *tctx, HPy h1, HPy h2, HPy h3) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 129); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 128); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_InPlacePower(uctx, h1, h2, h3); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 129, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 128, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_InPlaceLshift(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 130); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 129); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_InPlaceLshift(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 130, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 129, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_InPlaceRshift(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 131); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 130); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_InPlaceRshift(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 131, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 130, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_InPlaceAnd(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 132); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 131); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_InPlaceAnd(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 132, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 131, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_InPlaceXor(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 133); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 132); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_InPlaceXor(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 133, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 132, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_InPlaceOr(HPyContext *tctx, HPy h1, HPy h2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 134); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 133); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_InPlaceOr(uctx, h1, h2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 134, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 133, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_Callable_Check(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 135); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 134); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPyCallable_Check(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 135, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 134, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_CallTupleDict(HPyContext *tctx, HPy callable, HPy args, HPy kw) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 136); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 135); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_CallTupleDict(uctx, callable, args, kw); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 136, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 135, r0, r1, &_ts_start, &_ts_end); return res; } void trace_ctx_Err_SetString(HPyContext *tctx, HPy h_type, const char *message) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 138); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 137); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyErr_SetString(uctx, h_type, message); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 138, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 137, r0, r1, &_ts_start, &_ts_end); } void trace_ctx_Err_SetObject(HPyContext *tctx, HPy h_type, HPy h_value) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 139); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 138); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyErr_SetObject(uctx, h_type, h_value); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 139, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 138, r0, r1, &_ts_start, &_ts_end); } HPy trace_ctx_Err_SetFromErrnoWithFilename(HPyContext *tctx, HPy h_type, const char *filename_fsencoded) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 140); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 139); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyErr_SetFromErrnoWithFilename(uctx, h_type, filename_fsencoded); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 140, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 139, r0, r1, &_ts_start, &_ts_end); return res; } void trace_ctx_Err_SetFromErrnoWithFilenameObjects(HPyContext *tctx, HPy h_type, HPy filename1, HPy filename2) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 141); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 140); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyErr_SetFromErrnoWithFilenameObjects(uctx, h_type, filename1, filename2); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 141, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 140, r0, r1, &_ts_start, &_ts_end); } int trace_ctx_Err_Occurred(HPyContext *tctx) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 142); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 141); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPyErr_Occurred(uctx); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 142, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 141, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_Err_ExceptionMatches(HPyContext *tctx, HPy exc) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 143); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 142); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPyErr_ExceptionMatches(uctx, exc); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 143, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 142, r0, r1, &_ts_start, &_ts_end); return res; } void trace_ctx_Err_NoMemory(HPyContext *tctx) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 144); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 143); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyErr_NoMemory(uctx); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 144, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 143, r0, r1, &_ts_start, &_ts_end); } void trace_ctx_Err_Clear(HPyContext *tctx) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 145); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 144); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyErr_Clear(uctx); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 145, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 144, r0, r1, &_ts_start, &_ts_end); } HPy trace_ctx_Err_NewException(HPyContext *tctx, const char *name, HPy base, HPy dict) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 146); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 145); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyErr_NewException(uctx, name, base, dict); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 146, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 145, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Err_NewExceptionWithDoc(HPyContext *tctx, const char *name, const char *doc, HPy base, HPy dict) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 147); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 146); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyErr_NewExceptionWithDoc(uctx, name, doc, base, dict); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 147, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 146, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_Err_WarnEx(HPyContext *tctx, HPy category, const char *message, HPy_ssize_t stack_level) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 148); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 147); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPyErr_WarnEx(uctx, category, message, stack_level); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 148, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 147, r0, r1, &_ts_start, &_ts_end); return res; } void trace_ctx_Err_WriteUnraisable(HPyContext *tctx, HPy obj) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 149); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 148); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyErr_WriteUnraisable(uctx, obj); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 149, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 148, r0, r1, &_ts_start, &_ts_end); } int trace_ctx_IsTrue(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 150); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 149); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPy_IsTrue(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 150, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 149, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Type_FromSpec(HPyContext *tctx, HPyType_Spec *spec, HPyType_SpecParam *params) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 151); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 150); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyType_FromSpec(uctx, spec, params); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 151, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 150, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Type_GenericNew(HPyContext *tctx, HPy type, HPy *args, HPy_ssize_t nargs, HPy kw) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 152); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 151); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyType_GenericNew(uctx, type, args, nargs, kw); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 152, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 151, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_GetAttr(HPyContext *tctx, HPy obj, HPy name) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 153); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 152); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_GetAttr(uctx, obj, name); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 153, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 152, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_GetAttr_s(HPyContext *tctx, HPy obj, const char *name) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 154); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 153); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_GetAttr_s(uctx, obj, name); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 154, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 153, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_HasAttr(HPyContext *tctx, HPy obj, HPy name) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 155); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 154); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPy_HasAttr(uctx, obj, name); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 155, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 154, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_HasAttr_s(HPyContext *tctx, HPy obj, const char *name) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 156); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 155); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPy_HasAttr_s(uctx, obj, name); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 156, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 155, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_SetAttr(HPyContext *tctx, HPy obj, HPy name, HPy value) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 157); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 156); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPy_SetAttr(uctx, obj, name, value); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 157, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 156, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_SetAttr_s(HPyContext *tctx, HPy obj, const char *name, HPy value) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 158); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 157); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPy_SetAttr_s(uctx, obj, name, value); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 158, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 157, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_GetItem(HPyContext *tctx, HPy obj, HPy key) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 159); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 158); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_GetItem(uctx, obj, key); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 159, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 158, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_GetItem_i(HPyContext *tctx, HPy obj, HPy_ssize_t idx) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 160); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 159); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_GetItem_i(uctx, obj, idx); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 160, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 159, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_GetItem_s(HPyContext *tctx, HPy obj, const char *key) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 161); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 160); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_GetItem_s(uctx, obj, key); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 161, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 160, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_Contains(HPyContext *tctx, HPy container, HPy key) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 162); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 161); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPy_Contains(uctx, container, key); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 162, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 161, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_SetItem(HPyContext *tctx, HPy obj, HPy key, HPy value) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 163); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 162); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPy_SetItem(uctx, obj, key, value); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 163, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 162, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_SetItem_i(HPyContext *tctx, HPy obj, HPy_ssize_t idx, HPy value) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 164); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 163); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPy_SetItem_i(uctx, obj, idx, value); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 164, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 163, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_SetItem_s(HPyContext *tctx, HPy obj, const char *key, HPy value) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 165); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 164); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPy_SetItem_s(uctx, obj, key, value); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 165, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 164, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_DelItem(HPyContext *tctx, HPy obj, HPy key) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 236); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 235); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPy_DelItem(uctx, obj, key); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 236, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 235, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_DelItem_i(HPyContext *tctx, HPy obj, HPy_ssize_t idx) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 237); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 236); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPy_DelItem_i(uctx, obj, idx); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 237, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 236, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_DelItem_s(HPyContext *tctx, HPy obj, const char *key) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 238); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 237); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPy_DelItem_s(uctx, obj, key); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 238, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 237, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Type(HPyContext *tctx, HPy obj) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 166); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 165); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Type(uctx, obj); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 166, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 165, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_TypeCheck(HPyContext *tctx, HPy obj, HPy type) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 167); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 166); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPy_TypeCheck(uctx, obj, type); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 167, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 166, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_Is(HPyContext *tctx, HPy obj, HPy other) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 168); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 167); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPy_Is(uctx, obj, other); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 168, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 167, r0, r1, &_ts_start, &_ts_end); return res; } void *trace_ctx_AsStruct_Object(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 169); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 168); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); void * res = _HPy_AsStruct_Object(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 169, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 168, r0, r1, &_ts_start, &_ts_end); return res; } void *trace_ctx_AsStruct_Legacy(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 170); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 169); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); void * res = _HPy_AsStruct_Legacy(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 170, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 169, r0, r1, &_ts_start, &_ts_end); return res; } void *trace_ctx_AsStruct_Type(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 229); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 228); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); void * res = _HPy_AsStruct_Type(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 229, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 228, r0, r1, &_ts_start, &_ts_end); return res; } void *trace_ctx_AsStruct_Long(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 230); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 229); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); void * res = _HPy_AsStruct_Long(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 230, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 229, r0, r1, &_ts_start, &_ts_end); return res; } void *trace_ctx_AsStruct_Float(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 231); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 230); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); void * res = _HPy_AsStruct_Float(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 231, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 230, r0, r1, &_ts_start, &_ts_end); return res; } void *trace_ctx_AsStruct_Unicode(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 232); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 231); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); void * res = _HPy_AsStruct_Unicode(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 232, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 231, r0, r1, &_ts_start, &_ts_end); return res; } void *trace_ctx_AsStruct_Tuple(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 233); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 232); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); void * res = _HPy_AsStruct_Tuple(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 233, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 232, r0, r1, &_ts_start, &_ts_end); return res; } void *trace_ctx_AsStruct_List(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 234); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 233); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); void * res = _HPy_AsStruct_List(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 234, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 233, r0, r1, &_ts_start, &_ts_end); return res; } HPyType_BuiltinShape trace_ctx_Type_GetBuiltinShape(HPyContext *tctx, HPy h_type) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 235); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 234); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyType_BuiltinShape res = _HPyType_GetBuiltinShape(uctx, h_type); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 235, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 234, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_New(HPyContext *tctx, HPy h_type, void **data) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 171); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 170); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = _HPy_New(uctx, h_type, data); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 171, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 170, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Repr(HPyContext *tctx, HPy obj) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 172); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 171); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Repr(uctx, obj); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 172, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 171, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Str(HPyContext *tctx, HPy obj) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 173); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 172); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Str(uctx, obj); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 173, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 172, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_ASCII(HPyContext *tctx, HPy obj) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 174); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 173); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_ASCII(uctx, obj); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 174, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 173, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Bytes(HPyContext *tctx, HPy obj) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 175); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 174); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_Bytes(uctx, obj); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 175, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 174, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_RichCompare(HPyContext *tctx, HPy v, HPy w, int op) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 176); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 175); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_RichCompare(uctx, v, w, op); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 176, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 175, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_RichCompareBool(HPyContext *tctx, HPy v, HPy w, int op) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 177); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 176); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPy_RichCompareBool(uctx, v, w, op); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 177, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 176, r0, r1, &_ts_start, &_ts_end); return res; } HPy_hash_t trace_ctx_Hash(HPyContext *tctx, HPy obj) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 178); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 177); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy_hash_t res = HPy_Hash(uctx, obj); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 178, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 177, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_Bytes_Check(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 179); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 178); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPyBytes_Check(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 179, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 178, r0, r1, &_ts_start, &_ts_end); return res; } HPy_ssize_t trace_ctx_Bytes_Size(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 180); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 179); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy_ssize_t res = HPyBytes_Size(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 180, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 179, r0, r1, &_ts_start, &_ts_end); return res; } HPy_ssize_t trace_ctx_Bytes_GET_SIZE(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 181); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 180); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy_ssize_t res = HPyBytes_GET_SIZE(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 181, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 180, r0, r1, &_ts_start, &_ts_end); return res; } const char *trace_ctx_Bytes_AsString(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 182); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 181); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); const char * res = HPyBytes_AsString(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 182, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 181, r0, r1, &_ts_start, &_ts_end); return res; } const char *trace_ctx_Bytes_AS_STRING(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 183); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 182); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); const char * res = HPyBytes_AS_STRING(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 183, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 182, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Bytes_FromString(HPyContext *tctx, const char *v) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 184); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 183); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyBytes_FromString(uctx, v); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 184, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 183, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Bytes_FromStringAndSize(HPyContext *tctx, const char *v, HPy_ssize_t len) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 185); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 184); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyBytes_FromStringAndSize(uctx, v, len); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 185, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 184, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Unicode_FromString(HPyContext *tctx, const char *utf8) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 186); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 185); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyUnicode_FromString(uctx, utf8); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 186, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 185, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_Unicode_Check(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 187); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 186); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPyUnicode_Check(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 187, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 186, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Unicode_AsASCIIString(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 188); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 187); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyUnicode_AsASCIIString(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 188, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 187, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Unicode_AsLatin1String(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 189); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 188); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyUnicode_AsLatin1String(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 189, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 188, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Unicode_AsUTF8String(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 190); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 189); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyUnicode_AsUTF8String(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 190, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 189, r0, r1, &_ts_start, &_ts_end); return res; } const char *trace_ctx_Unicode_AsUTF8AndSize(HPyContext *tctx, HPy h, HPy_ssize_t *size) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 191); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 190); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); const char * res = HPyUnicode_AsUTF8AndSize(uctx, h, size); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 191, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 190, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Unicode_FromWideChar(HPyContext *tctx, const wchar_t *w, HPy_ssize_t size) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 192); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 191); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyUnicode_FromWideChar(uctx, w, size); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 192, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 191, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Unicode_DecodeFSDefault(HPyContext *tctx, const char *v) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 193); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 192); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyUnicode_DecodeFSDefault(uctx, v); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 193, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 192, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Unicode_DecodeFSDefaultAndSize(HPyContext *tctx, const char *v, HPy_ssize_t size) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 194); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 193); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyUnicode_DecodeFSDefaultAndSize(uctx, v, size); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 194, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 193, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Unicode_EncodeFSDefault(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 195); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 194); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyUnicode_EncodeFSDefault(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 195, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 194, r0, r1, &_ts_start, &_ts_end); return res; } HPy_UCS4 trace_ctx_Unicode_ReadChar(HPyContext *tctx, HPy h, HPy_ssize_t index) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 196); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 195); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy_UCS4 res = HPyUnicode_ReadChar(uctx, h, index); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 196, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 195, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Unicode_DecodeASCII(HPyContext *tctx, const char *s, HPy_ssize_t size, const char *errors) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 197); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 196); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyUnicode_DecodeASCII(uctx, s, size, errors); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 197, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 196, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Unicode_DecodeLatin1(HPyContext *tctx, const char *s, HPy_ssize_t size, const char *errors) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 198); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 197); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyUnicode_DecodeLatin1(uctx, s, size, errors); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 198, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 197, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_List_Check(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 199); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 198); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPyList_Check(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 199, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 198, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_List_New(HPyContext *tctx, HPy_ssize_t len) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 200); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 199); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyList_New(uctx, len); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 200, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 199, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_List_Append(HPyContext *tctx, HPy h_list, HPy h_item) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 201); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 200); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPyList_Append(uctx, h_list, h_item); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 201, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 200, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_Dict_Check(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 202); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 201); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPyDict_Check(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 202, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 201, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Dict_New(HPyContext *tctx) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 203); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 202); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyDict_New(uctx); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 203, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 202, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_Tuple_Check(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 204); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 203); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPyTuple_Check(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 204, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 203, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Tuple_FromArray(HPyContext *tctx, HPy items[], HPy_ssize_t n) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 205); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 204); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyTuple_FromArray(uctx, items, n); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 205, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 204, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Import_ImportModule(HPyContext *tctx, const char *name) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 206); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 205); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyImport_ImportModule(uctx, name); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 206, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 205, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_Capsule_New(HPyContext *tctx, void *pointer, const char *name, HPyCapsule_Destructor *destructor) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 245); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 244); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyCapsule_New(uctx, pointer, name, destructor); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 245, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 244, r0, r1, &_ts_start, &_ts_end); return res; } void *trace_ctx_Capsule_Get(HPyContext *tctx, HPy capsule, _HPyCapsule_key key, const char *name) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 246); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 245); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); void * res = HPyCapsule_Get(uctx, capsule, key, name); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 246, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 245, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_Capsule_IsValid(HPyContext *tctx, HPy capsule, const char *name) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 247); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 246); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPyCapsule_IsValid(uctx, capsule, name); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 247, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 246, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_Capsule_Set(HPyContext *tctx, HPy capsule, _HPyCapsule_key key, void *value) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 248); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 247); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPyCapsule_Set(uctx, capsule, key, value); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 248, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 247, r0, r1, &_ts_start, &_ts_end); return res; } HPy trace_ctx_FromPyObject(HPyContext *tctx, cpy_PyObject *obj) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 207); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 206); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPy_FromPyObject(uctx, obj); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 207, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 206, r0, r1, &_ts_start, &_ts_end); return res; } cpy_PyObject *trace_ctx_AsPyObject(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 208); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 207); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); cpy_PyObject * res = HPy_AsPyObject(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 208, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 207, r0, r1, &_ts_start, &_ts_end); return res; } HPyListBuilder trace_ctx_ListBuilder_New(HPyContext *tctx, HPy_ssize_t initial_size) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 210); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 209); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyListBuilder res = HPyListBuilder_New(uctx, initial_size); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 210, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 209, r0, r1, &_ts_start, &_ts_end); return res; } void trace_ctx_ListBuilder_Set(HPyContext *tctx, HPyListBuilder builder, HPy_ssize_t index, HPy h_item) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 211); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 210); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyListBuilder_Set(uctx, builder, index, h_item); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 211, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 210, r0, r1, &_ts_start, &_ts_end); } HPy trace_ctx_ListBuilder_Build(HPyContext *tctx, HPyListBuilder builder) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 212); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 211); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyListBuilder_Build(uctx, builder); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 212, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 211, r0, r1, &_ts_start, &_ts_end); return res; } void trace_ctx_ListBuilder_Cancel(HPyContext *tctx, HPyListBuilder builder) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 213); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 212); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyListBuilder_Cancel(uctx, builder); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 213, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 212, r0, r1, &_ts_start, &_ts_end); } HPyTupleBuilder trace_ctx_TupleBuilder_New(HPyContext *tctx, HPy_ssize_t initial_size) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 214); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 213); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyTupleBuilder res = HPyTupleBuilder_New(uctx, initial_size); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 214, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 213, r0, r1, &_ts_start, &_ts_end); return res; } void trace_ctx_TupleBuilder_Set(HPyContext *tctx, HPyTupleBuilder builder, HPy_ssize_t index, HPy h_item) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 215); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 214); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyTupleBuilder_Set(uctx, builder, index, h_item); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 215, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 214, r0, r1, &_ts_start, &_ts_end); } HPy trace_ctx_TupleBuilder_Build(HPyContext *tctx, HPyTupleBuilder builder) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 216); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 215); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyTupleBuilder_Build(uctx, builder); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 216, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 215, r0, r1, &_ts_start, &_ts_end); return res; } void trace_ctx_TupleBuilder_Cancel(HPyContext *tctx, HPyTupleBuilder builder) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 217); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 216); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyTupleBuilder_Cancel(uctx, builder); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 217, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 216, r0, r1, &_ts_start, &_ts_end); } HPyTracker trace_ctx_Tracker_New(HPyContext *tctx, HPy_ssize_t size) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 218); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 217); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyTracker res = HPyTracker_New(uctx, size); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 218, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 217, r0, r1, &_ts_start, &_ts_end); return res; } int trace_ctx_Tracker_Add(HPyContext *tctx, HPyTracker ht, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 219); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 218); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); int res = HPyTracker_Add(uctx, ht, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 219, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 218, r0, r1, &_ts_start, &_ts_end); return res; } void trace_ctx_Tracker_ForgetAll(HPyContext *tctx, HPyTracker ht) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 220); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 219); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyTracker_ForgetAll(uctx, ht); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 220, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 219, r0, r1, &_ts_start, &_ts_end); } void trace_ctx_Tracker_Close(HPyContext *tctx, HPyTracker ht) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 221); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 220); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyTracker_Close(uctx, ht); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 221, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 220, r0, r1, &_ts_start, &_ts_end); } void trace_ctx_Field_Store(HPyContext *tctx, HPy target_object, HPyField *target_field, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 222); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 221); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyField_Store(uctx, target_object, target_field, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 222, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 221, r0, r1, &_ts_start, &_ts_end); } HPy trace_ctx_Field_Load(HPyContext *tctx, HPy source_object, HPyField source_field) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 223); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 222); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyField_Load(uctx, source_object, source_field); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 223, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 222, r0, r1, &_ts_start, &_ts_end); return res; } void trace_ctx_ReenterPythonExecution(HPyContext *tctx, HPyThreadState state) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 224); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 223); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy_ReenterPythonExecution(uctx, state); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 224, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 223, r0, r1, &_ts_start, &_ts_end); } HPyThreadState trace_ctx_LeavePythonExecution(HPyContext *tctx) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 225); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 224); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyThreadState res = HPy_LeavePythonExecution(uctx); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 225, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 224, r0, r1, &_ts_start, &_ts_end); return res; } void trace_ctx_Global_Store(HPyContext *tctx, HPyGlobal *global, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 226); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 225); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPyGlobal_Store(uctx, global, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 226, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 225, r0, r1, &_ts_start, &_ts_end); } HPy trace_ctx_Global_Load(HPyContext *tctx, HPyGlobal global) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 227); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 226); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); HPy res = HPyGlobal_Load(uctx, global); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 227, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 226, r0, r1, &_ts_start, &_ts_end); return res; } void trace_ctx_Dump(HPyContext *tctx, HPy h) { - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 228); + HPyTraceInfo *info = hpy_trace_on_enter(tctx, 227); HPyContext *uctx = info->uctx; _HPyTime_t _ts_start, _ts_end; _HPyClockStatus_t r0, r1; r0 = get_monotonic_clock(&_ts_start); _HPy_Dump(uctx, h); r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 228, r0, r1, &_ts_start, &_ts_end); + hpy_trace_on_exit(info, 227, r0, r1, &_ts_start, &_ts_end); } diff --git a/hpy/trace/src/include/hpy_trace.h b/hpy/trace/src/include/hpy_trace.h index 9fbed67f8..e75b76186 100644 --- a/hpy/trace/src/include/hpy_trace.h +++ b/hpy/trace/src/include/hpy_trace.h @@ -31,6 +31,12 @@ const char * hpy_trace_get_func_name(int idx); extern "C" #endif HPy_EXPORTED_SYMBOL -HPy HPyInit__trace(HPyContext *uctx); +HPyModuleDef* HPyInit__trace(); + +#ifdef ___cplusplus +extern "C" +#endif +HPy_EXPORTED_SYMBOL +void HPyInitGlobalContext__trace(HPyContext *ctx); #endif /* HPY_TRACE_H */ diff --git a/hpy/universal/src/autogen_ctx_def.h b/hpy/universal/src/autogen_ctx_def.h index ec4a3a324..e0337e780 100644 --- a/hpy/universal/src/autogen_ctx_def.h +++ b/hpy/universal/src/autogen_ctx_def.h @@ -15,7 +15,6 @@ struct _HPyContext_s g_universal_ctx = { ._private = NULL, .abi_version = HPY_ABI_VERSION, /* h_None & co. are initialized by init_universal_ctx() */ - .ctx_Module_Create = &ctx_Module_Create, .ctx_Dup = &ctx_Dup, .ctx_Close = &ctx_Close, .ctx_Long_FromLong = &ctx_Long_FromLong, diff --git a/hpy/universal/src/ctx_meth.c b/hpy/universal/src/ctx_meth.c index 2739a0ba0..119672755 100644 --- a/hpy/universal/src/ctx_meth.c +++ b/hpy/universal/src/ctx_meth.c @@ -1,6 +1,7 @@ #include #include "ctx_meth.h" #include "hpy/runtime/ctx_type.h" +#include "hpy/runtime/ctx_module.h" #include "handles.h" static void _buffer_h2py(HPyContext *ctx, const HPy_buffer *src, Py_buffer *dest) @@ -120,6 +121,13 @@ ctx_CallRealFunctionFromTrampoline(HPyContext *ctx, HPyFunc_Signature sig, PyCapsule_GetContext(capsule)); return; } + case HPyFunc_MOD_CREATE: { + HPyFunc_unaryfunc f = (HPyFunc_unaryfunc)func; + _HPyFunc_args_UNARYFUNC *a = (_HPyFunc_args_UNARYFUNC*)args; + a->result = _h2py(f(ctx, _py2h(a->arg0))); + _HPyModule_CheckCreateSlotResult(&a->result); + return; + } #include "autogen_ctx_call.i" default: Py_FatalError("Unsupported HPyFunc_Signature in ctx_meth.c"); diff --git a/hpy/universal/src/hpymodule.c b/hpy/universal/src/hpymodule.c index f2798725a..75fedd2f5 100644 --- a/hpy/universal/src/hpymodule.c +++ b/hpy/universal/src/hpymodule.c @@ -17,6 +17,7 @@ #include "hpy/version.h" #include "hpy_debug.h" #include "hpy_trace.h" +#include "hpy/runtime/ctx_module.h" #ifdef PYPY_VERSION # error "Cannot build hpy.universal on top of PyPy. PyPy comes with its own version of it" @@ -45,9 +46,12 @@ typedef enum { // MODE_TRACE_DEBUG = 4 } HPyMode; -typedef HPy (*InitFuncPtr)(HPyContext *ctx); +typedef uint32_t (*VersionGetterFuncPtr)(void); +typedef HPyModuleDef* (*InitFuncPtr)(void); +typedef void (*InitContextFuncPtr)(HPyContext*); -static const char *prefix = "HPyInit"; +static const char *init_prefix = "HPyInit"; +static const char *init_ctx_prefix = "HPyInitGlobalContext_"; static inline int _hpy_strncmp_ignore_case(const char *s0, const char *s1, size_t n) @@ -149,21 +153,28 @@ static bool validate_abi_tag(const char *shortname, const char *soname, return false; } -typedef uint32_t (*version_getter)(void); +static void dlsym_error(const char *soname, const char *symbol_name) { + const char *error = dlerror(); + if (error == NULL) + error = "no error message provided by the system"; + PyErr_Format(PyExc_RuntimeError, + "Error during loading of the HPy extension module at " + "path '%s' while trying to find symbol '%s'. Did you use" + "the HPy_MODINIT macro to register your module? Error " + "message from dlsym/WinAPI: %s", soname, symbol_name, error); +} -static PyObject *do_load(PyObject *name_unicode, PyObject *path, HPyMode mode) +static PyObject *do_load(PyObject *name_unicode, PyObject *path, HPyMode mode, PyObject *spec) { PyObject *name = NULL; PyObject *pathbytes = NULL; + PyModuleDef *pydef = NULL; + PyObject *py_mod = NULL; name = get_encoded_name(name_unicode); if (name == NULL) { goto error; } - const char *shortname = PyBytes_AS_STRING(name); - char init_name[258]; - PyOS_snprintf(init_name, sizeof(init_name), "%.20s_%.200s", - prefix, shortname); pathbytes = PyUnicode_EncodeFSDefault(path); if (pathbytes == NULL) @@ -181,11 +192,12 @@ static PyObject *do_load(PyObject *name_unicode, PyObject *path, HPyMode mode) goto error; } + const char *shortname = PyBytes_AS_STRING(name); char minor_version_symbol_name[258]; char major_version_symbol_name[258]; - PyOS_snprintf(minor_version_symbol_name, sizeof(init_name), + PyOS_snprintf(minor_version_symbol_name, sizeof(minor_version_symbol_name), "get_required_hpy_minor_version_%.200s", shortname); - PyOS_snprintf(major_version_symbol_name, sizeof(init_name), + PyOS_snprintf(major_version_symbol_name, sizeof(major_version_symbol_name), "get_required_hpy_major_version_%.200s", shortname); void *minor_version_ptr = dlsym(mylib, minor_version_symbol_name); void *major_version_ptr = dlsym(mylib, major_version_symbol_name); @@ -200,8 +212,8 @@ static PyObject *do_load(PyObject *name_unicode, PyObject *path, HPyMode mode) soname, minor_version_symbol_name, major_version_symbol_name, error); goto error; } - uint32_t required_minor_version = ((version_getter) minor_version_ptr)(); - uint32_t required_major_version = ((version_getter) major_version_ptr)(); + uint32_t required_minor_version = ((VersionGetterFuncPtr) minor_version_ptr)(); + uint32_t required_major_version = ((VersionGetterFuncPtr) major_version_ptr)(); if (required_major_version != HPY_ABI_VERSION || required_minor_version > HPY_ABI_VERSION_MINOR) { // For now, we have only one major version, but in the future at this // point we would decide which HPyContext to create @@ -218,32 +230,58 @@ static PyObject *do_load(PyObject *name_unicode, PyObject *path, HPyMode mode) goto error; } + HPyContext *ctx = get_context(mode); + if (ctx == NULL) + goto error; + + char init_ctx_name[258]; + PyOS_snprintf(init_ctx_name, sizeof(init_ctx_name), "%.20s_%.200s", + init_ctx_prefix, shortname); + void *initctxfn = dlsym(mylib, init_ctx_name); + if (initctxfn == NULL) { + dlsym_error(soname, init_ctx_name); + goto error; + } + ((InitContextFuncPtr)initctxfn)(ctx); + + char init_name[258]; + PyOS_snprintf(init_name, sizeof(init_name), "%.20s_%.200s", + init_prefix, shortname); void *initfn = dlsym(mylib, init_name); if (initfn == NULL) { - const char *error = dlerror(); - if (error == NULL) - error = "no error message provided by the system"; + dlsym_error(soname, init_name); + goto error; + } + + HPyModuleDef* hpydef = ((InitFuncPtr)initfn)(); + if (hpydef == NULL) { PyErr_Format(PyExc_RuntimeError, "Error during loading of the HPy extension module at " - "path '%s' while trying to find symbol '%s'. Did you use" - "the HPy_MODINIT macro to register your module? Error " - "message from dlsym/WinAPI: %s", soname, init_name, error); + "path '%s'. Function '%s' returned NULL.", soname, init_name); goto error; } - HPyContext *ctx = get_context(mode); - if (ctx == NULL) + pydef = _HPyModuleDef_CreatePyModuleDef(hpydef); + if (pydef == NULL) { goto error; - HPy h_mod = ((InitFuncPtr)initfn)(ctx); - if (HPy_IsNull(h_mod)) + } + + py_mod = PyModule_FromDefAndSpec(pydef, spec); + if (py_mod == NULL) goto error; - PyObject *py_mod = HPy_AsPyObject(ctx, h_mod); - HPy_Close(ctx, h_mod); + + if (PyModule_Check(py_mod)) { + if (PyModule_ExecDef(py_mod, pydef) != 0) + goto error; + } Py_XDECREF(name); Py_XDECREF(pathbytes); return py_mod; error: + Py_XDECREF(py_mod); + if (pydef != NULL) + PyMem_Free(pydef); Py_XDECREF(name); Py_XDECREF(pathbytes); return NULL; @@ -251,13 +289,14 @@ static PyObject *do_load(PyObject *name_unicode, PyObject *path, HPyMode mode) static PyObject *load(PyObject *self, PyObject *args, PyObject *kwargs) { - static char *kwlist[] = {"name", "path", "debug", "mode", NULL}; + static char *kwlist[] = {"name", "path", "spec", "debug", "mode", NULL}; PyObject *name_unicode; PyObject *path; + PyObject *spec; int debug = 0; int mode = -1; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|pi", kwlist, - &name_unicode, &path, &debug, &mode)) { + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO|pi", kwlist, + &name_unicode, &path, &spec, &debug, &mode)) { return NULL; } HPyMode hmode = debug ? MODE_DEBUG : MODE_UNIVERSAL; @@ -266,7 +305,7 @@ static PyObject *load(PyObject *self, PyObject *args, PyObject *kwargs) { hmode = (HPyMode) mode; } - return do_load(name_unicode, path, hmode); + return do_load(name_unicode, path, hmode, spec); } static HPyMode get_mode_from_string(const char *s, Py_ssize_t n) @@ -424,7 +463,7 @@ load_bootstrap(PyObject *self, PyObject *args, PyObject *kwargs) s_module_name, log_msg); } - m = do_load(module_name, file, hmode); + m = do_load(module_name, file, hmode, spec); if (m == NULL) return NULL; @@ -464,7 +503,7 @@ static PyModuleDef_Slot hpymodule_slots[] = { {0, NULL}, }; -static struct PyModuleDef hpydef = { +static struct PyModuleDef hpy_pydef = { PyModuleDef_HEAD_INIT, .m_name = "hpy.universal", .m_doc = "HPy universal runtime for CPython", @@ -473,27 +512,58 @@ static struct PyModuleDef hpydef = { .m_slots = hpymodule_slots, }; +static int initialize_module(HPyContext *ctx, PyObject *hpy_universal, const char* name, + const char *full_name, HPyModuleDef *hpydef, + PyObject* spec_from_file_and_location, PyObject *location) +{ + PyObject *spec = NULL, *new_mod = NULL; + int result = -1; + + spec = PyObject_CallFunction(spec_from_file_and_location, "sO", full_name, location); + PyModuleDef *pydef = _HPyModuleDef_CreatePyModuleDef(hpydef); + new_mod = PyModule_FromDefAndSpec(pydef, spec); + if (new_mod == NULL) + goto cleanup; + + if (PyModule_ExecDef(new_mod, pydef) != 0) + goto cleanup; + + if (PyModule_AddObject(hpy_universal, name, new_mod) < 0) + goto cleanup; + + result = 0; + +cleanup: + Py_XDECREF(new_mod); + Py_XDECREF(spec); + return result; +} // module initialization function int exec_module(PyObject* mod) { HPyContext *ctx = &g_universal_ctx; - HPy h_debug_mod = HPyInit__debug(ctx); - if (HPy_IsNull(h_debug_mod)) - return -1; - PyObject *_debug_mod = HPy_AsPyObject(ctx, h_debug_mod); - HPy_Close(ctx, h_debug_mod); - if (PyModule_AddObject(mod, "_debug", _debug_mod) < 0) + PyObject *importlib_util = PyImport_ImportModule("importlib.util"); + if (importlib_util == NULL) { return -1; + } - HPy h_trace_mod = HPyInit__trace(ctx); - if (HPy_IsNull(h_trace_mod)) + PyObject *spec_from_file_and_location = PyObject_GetAttrString(importlib_util, "spec_from_file_location"); + if (spec_from_file_and_location == NULL) { return -1; - PyObject *_trace_mod = HPy_AsPyObject(ctx, h_trace_mod); - HPy_Close(ctx, h_trace_mod); + } + Py_DecRef(importlib_util); - if (PyModule_AddObject(mod, "_trace", _trace_mod) < 0) - return -1; + PyObject *current_mod_spec = PyObject_GetAttrString(mod, "__spec__"); + PyObject *location = PyObject_GetAttrString(current_mod_spec, "origin"); + + HPyInitGlobalContext__debug(ctx); + initialize_module(ctx, mod, "_debug", "hpy.debug._debug", + HPyInit__debug(), spec_from_file_and_location, location); + + HPyInitGlobalContext__trace(ctx); + initialize_module(ctx, mod, "_trace", "hpy.debug._trace", + HPyInit__trace(), spec_from_file_and_location, location); for (int i=0; hpy_mode_names[i]; i++) { @@ -607,6 +677,6 @@ PyMODINIT_FUNC PyInit_universal(void) { init_universal_ctx(&g_universal_ctx); - PyObject *mod = PyModuleDef_Init(&hpydef); + PyObject *mod = PyModuleDef_Init(&hpy_pydef); return mod; } diff --git a/proof-of-concept/pof.c b/proof-of-concept/pof.c index 37f74b271..4b9527332 100644 --- a/proof-of-concept/pof.c +++ b/proof-of-concept/pof.c @@ -79,30 +79,30 @@ static HPyType_Spec point_type_spec = { .defines = point_type_defines }; +HPyDef_SLOT(mod_exec, HPy_mod_exec) +static int mod_exec_impl(HPyContext *ctx, HPy m) +{ + HPy h_point_type = HPyType_FromSpec(ctx, &point_type_spec, NULL); + if (HPy_IsNull(h_point_type)) + return -1; + HPy_SetAttr_s(ctx, m, "Point", h_point_type); + HPy_Close(ctx, h_point_type); + return 0; +} + static HPyDef *module_defines[] = { &do_nothing, &double_obj, &add_ints, &add_ints_kw, + &mod_exec, NULL }; + static HPyModuleDef moduledef = { - .name = "pof", .doc = "HPy Proof of Concept", - .size = -1, + .size = 0, .defines = module_defines }; -HPy_MODINIT(pof) -static HPy init_pof_impl(HPyContext *ctx) -{ - HPy m, h_point_type; - m = HPyModule_Create(ctx, &moduledef); - if (HPy_IsNull(m)) - return HPy_NULL; - h_point_type = HPyType_FromSpec(ctx, &point_type_spec, NULL); - if (HPy_IsNull(h_point_type)) - return HPy_NULL; - HPy_SetAttr_s(ctx, m, "Point", h_point_type); - return m; -} +HPy_MODINIT(pof, moduledef) \ No newline at end of file diff --git a/proof-of-concept/pofcpp.cpp b/proof-of-concept/pofcpp.cpp index 94b95f919..004b4a04a 100644 --- a/proof-of-concept/pofcpp.cpp +++ b/proof-of-concept/pofcpp.cpp @@ -72,6 +72,7 @@ static HPyDef *point_type_defines[] = { &Point_repr, NULL }; + static HPyType_Spec point_type_spec = { .name = "pofcpp.Point", .basicsize = sizeof(PointObject), @@ -79,17 +80,28 @@ static HPyType_Spec point_type_spec = { .defines = point_type_defines }; +HPyDef_SLOT(mod_exec, HPy_mod_exec) +static int mod_exec_impl(HPyContext *ctx, HPy m) +{ + HPy h_point_type = HPyType_FromSpec(ctx, &point_type_spec, NULL); + if (HPy_IsNull(h_point_type)) + return -1; + HPy_SetAttr_s(ctx, m, "Point", h_point_type); + HPy_Close(ctx, h_point_type); + return 0; +} + static HPyDef *module_defines[] = { &do_nothing, &double_obj, &add_ints, &add_ints_kw, + &mod_exec, NULL }; static HPyModuleDef moduledef = { - .name = "pofcpp", .doc = "HPy c++ Proof of Concept", - .size = -1, + .size = 0, .defines = module_defines }; @@ -97,19 +109,7 @@ static HPyModuleDef moduledef = { extern "C" { #endif -HPy_MODINIT(pofcpp) -static HPy init_pofcpp_impl(HPyContext *ctx) -{ - HPy m, h_point_type; - m = HPyModule_Create(ctx, &moduledef); - if (HPy_IsNull(m)) - return HPy_NULL; - h_point_type = HPyType_FromSpec(ctx, &point_type_spec, NULL); - if (HPy_IsNull(h_point_type)) - return HPy_NULL; - HPy_SetAttr_s(ctx, m, "Point", h_point_type); - return m; -} +HPy_MODINIT(pofcpp, moduledef) #ifdef __cplusplus } diff --git a/proof-of-concept/pofpackage/bar.cpp b/proof-of-concept/pofpackage/bar.cpp index 724fde7c8..01726d2d6 100644 --- a/proof-of-concept/pofpackage/bar.cpp +++ b/proof-of-concept/pofpackage/bar.cpp @@ -28,9 +28,8 @@ static HPyDef *module_defines[] = { NULL }; static HPyModuleDef moduledef = { - .name = "bar", .doc = "HPy C++ Proof of Concept", - .size = -1, + .size = 0, .defines = module_defines }; @@ -39,15 +38,7 @@ extern "C" { #endif -HPy_MODINIT(bar) -static HPy init_bar_impl(HPyContext *ctx) -{ - HPy m; - m = HPyModule_Create(ctx, &moduledef); - if (HPy_IsNull(m)) - return HPy_NULL; - return m; -} +HPy_MODINIT(bar, moduledef) #ifdef __cplusplus } diff --git a/proof-of-concept/pofpackage/foo.c b/proof-of-concept/pofpackage/foo.c index 4b0b9e443..3a265efa2 100644 --- a/proof-of-concept/pofpackage/foo.c +++ b/proof-of-concept/pofpackage/foo.c @@ -12,18 +12,9 @@ static HPyDef *module_defines[] = { NULL }; static HPyModuleDef moduledef = { - .name = "foo", .doc = "HPy Proof of Concept", - .size = -1, + .size = 0, .defines = module_defines }; -HPy_MODINIT(foo) -static HPy init_foo_impl(HPyContext *ctx) -{ - HPy m; - m = HPyModule_Create(ctx, &moduledef); - if (HPy_IsNull(m)) - return HPy_NULL; - return m; -} +HPy_MODINIT(foo, moduledef) diff --git a/test/support.py b/test/support.py index 232253f7a..ab7be130a 100644 --- a/test/support.py +++ b/test/support.py @@ -76,36 +76,35 @@ class DefaultExtensionTemplate(object): INIT_TEMPLATE = textwrap.dedent( """ + HPyDef_SLOT(generated_init, HPy_mod_exec) + static int generated_init_impl(HPyContext *ctx, HPy m) + { + // Shouldn't really happen, but jut to silence the unused label warning + if (HPy_IsNull(m)) + goto MODINIT_ERROR; + + %(init_types)s + return 0; + + MODINIT_ERROR: + return -1; + } + static HPyDef *moduledefs[] = { %(defines)s + &generated_init, NULL }; %(globals_defs)s static HPyModuleDef moduledef = { - .name = "%(name)s", .doc = "some test for hpy", - .size = -1, + .size = 0, .legacy_methods = %(legacy_methods)s, .defines = moduledefs, %(globals_field)s }; - HPy_MODINIT(%(name)s) - static HPy init_%(name)s_impl(HPyContext *ctx) - { - HPy m = HPy_NULL; - m = HPyModule_Create(ctx, &moduledef); - if (HPy_IsNull(m)) - goto MODINIT_ERROR; - %(init_types)s - return m; - - MODINIT_ERROR: - - if (!HPy_IsNull(m)) - HPy_Close(ctx, m); - return HPy_NULL; - } + HPy_MODINIT(%(name)s, moduledef) """) r_marker = re.compile(r"^\s*@([A-Za-z_]+)(\(.*\))?$") @@ -206,6 +205,9 @@ def EXTRA_INIT_FUNC(self, func): src = reindent(src, 4) self.type_table.append(src.format(func=func)) + def HPy_MODINIT(self, mod): + return "HPy_MODINIT({}, {})".format(self.name, mod) + class Spec(object): def __init__(self, name, origin): @@ -354,9 +356,12 @@ def load_universal_module(self, name, so_filename, mode): 'trace', 'hybrid+trace') import sys import hpy.universal + import importlib.util assert name not in sys.modules - mod = hpy.universal.load(name, so_filename, mode=mode) + spec = importlib.util.spec_from_file_location(name, so_filename) + mod = hpy.universal.load(name, so_filename, spec, mode=mode) mod.__file__ = so_filename + mod.__spec__ = spec return mod def load_cpython_module(self, name, so_filename): diff --git a/test/test_hpymodule.py b/test/test_hpymodule.py index c513ccb84..f154485ff 100644 --- a/test/test_hpymodule.py +++ b/test/test_hpymodule.py @@ -1,26 +1,283 @@ +import types +import pytest from .support import HPyTest class TestModule(HPyTest): - def test_HPyModule_Create(self): + def test_HPyModule_simple(self): + """ + The simplest fully declarative module creation. + """ mod = self.make_module(""" HPyDef_METH(f, "f", HPyFunc_NOARGS) static HPy f_impl(HPyContext *ctx, HPy self) { - HPyModuleDef def = { - .name = "foo", + return HPyLong_FromLong(ctx, 42); + } + + static HPyDef *moduledefs[] = { &f, NULL }; + static HPyModuleDef moduledef = { + .doc = "Some doc", + .size = 0, + .legacy_methods = NULL, + .defines = moduledefs, + .globals = NULL, + }; + + @HPy_MODINIT(moduledef) + """) + assert mod.__name__ == mod.__spec__.name + assert mod.__doc__ == "Some doc" + assert mod.f() == 42 + + def test_HPyModule_custom_exec(self): + """ + Module that defines several exec slots. HPy specifies that the slots + will be executed in declaration order. Exec slots can add new types, + and other objects into the module. They can also initialize other + objects. The exec slots will be called on every new instance of the + module, for example, when it is imported in several subinterpreters. + """ + mod = self.make_module(""" + HPyDef_SLOT(exec1, HPy_mod_exec) + static int exec1_impl(HPyContext *ctx, HPy mod) + { + HPy list = HPyList_New(ctx, 0); + if (HPy_IsNull(list)) + return -1; + HPy_SetAttr_s(ctx, mod, "data", list); + HPy_Close(ctx, list); + return 0; + } + + HPyDef_SLOT(exec2, HPy_mod_exec) + static int exec2_impl(HPyContext *ctx, HPy mod) + { + HPy list = HPy_GetAttr_s(ctx, mod, "data"); + if (HPy_IsNull(list)) + return -1; + if (HPy_Length(ctx, list) != 0) { + HPyErr_SetString(ctx, ctx->h_RuntimeError, "Unexpected: len(list) != 0"); + return -1; + } + HPy item = HPyLong_FromLong(ctx, 42); + HPyList_Append(ctx, list, item); + HPy_Close(ctx, item); + HPy_Close(ctx, list); + return 0; + } + + static HPyDef *moduledefs[] = { + &exec1, + &exec2, + NULL + }; + + static HPyModuleDef moduledef = { + .doc = "Some doc", + .size = 0, + .legacy_methods = NULL, + .defines = moduledefs, + .globals = NULL, + }; + + @HPy_MODINIT(moduledef) + """) + assert mod.data == [42] + + def test_HPyModule_custom_create_returns_non_module(self): + """ + Module that defines create slot that returns non module object. This + is, for the time being, the only supported way to implement the module + 'create' slot. HPy intentionally does not expose direct API to create + a module object. Module objects are created for the extension by the + runtime and the extension can only populate that module object in the + init slots. + """ + mod = self.make_module(""" + HPyDef_SLOT(create, HPy_mod_create) + static HPy create_impl(HPyContext *ctx, HPy spec) + { + HPy result = HPy_NULL, dict = HPy_NULL, ns_type = HPy_NULL; + + HPy types = HPyImport_ImportModule(ctx, "types"); + if (HPy_IsNull(types)) + return HPy_NULL; + + ns_type = HPy_GetAttr_s(ctx, types, "SimpleNamespace"); + if (HPy_IsNull(types)) + goto cleanup; + dict = HPyDict_New(ctx); + HPy_SetItem_s(ctx, dict, "spec", spec); + result = HPy_CallTupleDict(ctx, ns_type, HPy_NULL, dict); + if (HPy_IsNull(result)) + goto cleanup; + + cleanup: + HPy_Close(ctx, dict); + HPy_Close(ctx, types); + HPy_Close(ctx, ns_type); + return result; + } + + static HPyDef *moduledefs[] = { + &create, + NULL + }; + + static HPyModuleDef moduledef = { + .doc = NULL, + .size = 0, + .legacy_methods = NULL, + .defines = moduledefs, + .globals = NULL, + }; + + @HPy_MODINIT(moduledef) + """) + assert isinstance(mod, types.SimpleNamespace) + assert mod.spec is mod.__spec__ + + def test_HPyModule_error_when_create_returns_module(self): + """ + The HPy_mod_create slot cannot return a builtin module object. + HPy does not expose any API to create builtin module objects and, until + there are any actual use-cases, the purpose of the 'create' slot is to + create non-builtin-module objects. + """ + expected_message = "HPy_mod_create slot returned a builtin module " \ + "object. This is currently not supported." + with pytest.raises(SystemError, match=expected_message): + self.make_module(""" + HPyDef_SLOT(create, HPy_mod_create) + static HPy create_impl(HPyContext *ctx, HPy spec) + { + return HPyImport_ImportModule(ctx, "types"); + } + + static HPyDef *moduledefs[] = { + &create, + NULL + }; + + static HPyModuleDef moduledef = { + .doc = NULL, + .size = 0, + .legacy_methods = NULL, + .defines = moduledefs, + .globals = NULL, + }; + + @HPy_MODINIT(moduledef) + """) + + def test_HPyModule_create_raises(self): + with pytest.raises(RuntimeError, match="Test error"): + self.make_module(""" + HPyDef_SLOT(create, HPy_mod_create) + static HPy create_impl(HPyContext *ctx, HPy spec) + { + HPyErr_SetString(ctx, ctx->h_RuntimeError, "Test error"); + return HPy_NULL; + } + + static HPyDef *moduledefs[] = { + &create, + NULL + }; + + static HPyModuleDef moduledef = { + .doc = NULL, + .size = 0, + .legacy_methods = NULL, + .defines = moduledefs, + .globals = NULL, + }; + + @HPy_MODINIT(moduledef) + """) + + def test_HPyModule_create_and_nondefault_values(self): + expected_message = r'^HPyModuleDef defines a HPy_mod_create slot.*' + with pytest.raises(SystemError, match=expected_message): + self.make_module(""" + HPyDef_SLOT(create, HPy_mod_create) + static HPy create_impl(HPyContext *ctx, HPy spec) + { + HPyErr_SetString(ctx, ctx->h_RuntimeError, "Test error"); + return HPy_NULL; + } + + static HPyDef *moduledefs[] = { + &create, + NULL + }; + + static HPyModuleDef moduledef = { + .doc = "Some doc - this is non-default", + .size = 0, + .legacy_methods = NULL, + .defines = moduledefs, + .globals = NULL, + }; + + @HPy_MODINIT(moduledef) + """) + + def test_HPyModule_create_and_exec_slots(self): + expected_message = r'^HPyModuleDef defines a HPy_mod_create slot.*' + with pytest.raises(SystemError, match=expected_message): + self.make_module(""" + HPyDef_SLOT(create, HPy_mod_create) + static HPy create_impl(HPyContext *ctx, HPy spec) + { + HPyErr_SetString(ctx, ctx->h_RuntimeError, "Test error"); + return HPy_NULL; + } + + HPyDef_SLOT(exec, HPy_mod_exec) + static int exec_impl(HPyContext *ctx, HPy mod) + { + return 0; + } + + static HPyDef *moduledefs[] = { + &create, + &exec, + NULL + }; + + static HPyModuleDef moduledef = { + .doc = NULL, + .size = 0, + .legacy_methods = NULL, + .defines = moduledefs, + .globals = NULL, + }; + + @HPy_MODINIT(moduledef) + """) + + def test_HPyModule_negative_size(self): + """ + The simplest fully declarative module creation. + """ + expected_message = "HPy does not permit HPyModuleDef.size < 0" + with pytest.raises(SystemError, match=expected_message): + self.make_module(""" + HPyDef_METH(f, "f", HPyFunc_NOARGS) + static HPy f_impl(HPyContext *ctx, HPy self) + { + return HPyLong_FromLong(ctx, 42); + } + + static HPyDef *moduledefs[] = { &f, NULL }; + static HPyModuleDef moduledef = { .doc = "Some doc", .size = -1, + .legacy_methods = NULL, + .defines = moduledefs, + .globals = NULL, }; - return HPyModule_Create(ctx, &def); - } - @EXPORT(f) - @INIT - """) - m = mod.f() - assert m.__name__ == "foo" - assert m.__doc__ == "Some doc" - assert m.__package__ is None - assert m.__loader__ is None - assert m.__spec__ is None - assert set(vars(m).keys()) == { - '__name__', '__doc__', '__package__', '__loader__', '__spec__'} + + @HPy_MODINIT(moduledef) + """)